BUG: raise ValueError if sharex, sharey point to a different figure by efiring · Pull Request #6463 · matplotlib/matplotlib · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/api/api_changes/2017-06-06-no_share_across_figures.rst
18 changes: 11 additions & 7 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ def __init__(self, fig, rect,

Optional keyword arguments:

================ =========================================
================ ==============================================
Keyword Description
================ =========================================
================ ==============================================
*adjustable* [ 'box' | 'datalim' | 'box-forced']
*alpha* float: the alpha transparency (can be None)
*anchor* [ 'C', 'SW', 'S', 'SE', 'E', 'NE', 'N',
Expand All @@ -458,10 +458,10 @@ def __init__(self, fig, rect,
toolbar button status
*position* [left, bottom, width, height] in
class:`~matplotlib.figure.Figure` coords
*sharex* an class:`~matplotlib.axes.Axes` instance
to share the x-axis with
*sharey* an class:`~matplotlib.axes.Axes` instance
to share the y-axis with
*sharex* another class:`~matplotlib.axes.Axes` instance
in *fig* to share the x-axis with
*sharey* another class:`~matplotlib.axes.Axes` instance
in *fig* to share the y-axis with
*title* the title string
*visible* [ *True* | *False* ] whether the axes is
visible
Expand All @@ -475,7 +475,7 @@ def __init__(self, fig, rect,
*yscale* [%(scale)s]
*yticklabels* sequence of strings
*yticks* sequence of floats
================ =========================================
================ ==============================================
""" % {'scale': ' | '.join(
[repr(x) for x in mscale.get_scale_names()])}
martist.Artist.__init__(self)
Expand All @@ -494,13 +494,17 @@ def __init__(self, fig, rect,
self._sharex = sharex
self._sharey = sharey
if sharex is not None:
if sharex.get_figure() is not fig:
raise ValueError('Shared Axes must be in the same figure')
self._shared_x_axes.join(self, sharex)
if sharex._adjustable == 'box':
sharex._adjustable = 'datalim'
# warnings.warn(
# 'shared axes: "adjustable" is being changed to "datalim"')
self._adjustable = 'datalim'
if sharey is not None:
if sharey.get_figure() is not fig:
raise ValueError('Shared Axes must be in the same figure')
self._shared_y_axes.join(self, sharey)
if sharey._adjustable == 'box':
sharey._adjustable = 'datalim'
Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_axes.py