Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 68cc2f3

Browse files
committed
Clarify axis sharing with aspect ratio control
- Axis sharing works across figures. - The "box-forced" adjustable is no longer needed. - Sharing both axes requires the use of "box", not "datalim". - A new "share" kwarg triggers synchronized setting of aspect ratio and adjustable in Axes within shared axis groups. - Added a test for axis sharing with aspect ratio setting. - Fixed and updated skew_rects test.
1 parent 3c1f423 commit 68cc2f3

File tree

8 files changed

+1744
-1652
lines changed

8 files changed

+1744
-1652
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 118 additions & 87 deletions
Large diffs are not rendered by default.

lib/matplotlib/axes/_subplots.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,21 @@ def label_outer(self):
144144

145145
def _make_twin_axes(self, *kl, **kwargs):
146146
"""
147-
make a twinx axes of self. This is used for twinx and twiny.
147+
Make a twinx axes of self. This is used for twinx and twiny.
148148
"""
149149
from matplotlib.projections import process_projection_requirements
150+
if 'sharex' in kwargs and 'sharey' in kwargs:
151+
raise ValueError("Twinned Axes may share only one axis.")
150152
kl = (self.get_subplotspec(),) + kl
151153
projection_class, kwargs, key = process_projection_requirements(
152154
self.figure, *kl, **kwargs)
153155

154156
ax2 = subplot_class_factory(projection_class)(self.figure,
155157
*kl, **kwargs)
156158
self.figure.add_subplot(ax2)
159+
self.set_adjustable('datalim')
160+
ax2.set_adjustable('datalim')
161+
self._twinned_axes.join(self, ax2)
157162
return ax2
158163

159164
_subplot_classes = {}
Binary file not shown.

0 commit comments

Comments
 (0)