Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 131ddad

Browse filesBrowse files
committed
FIX: better error message for shared axes and axis('equal')
1 parent a1eef38 commit 131ddad
Copy full SHA for 131ddad

File tree

Expand file treeCollapse file tree

1 file changed

+9
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-3
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,8 +1941,10 @@ def apply_aspect(self, position=None):
19411941
shared_y = self in self._shared_axes["y"]
19421942
# Not sure whether we need this check:
19431943
if shared_x and shared_y:
1944-
raise RuntimeError("adjustable='datalim' is not allowed when both "
1945-
"axes are shared")
1944+
raise RuntimeError("set_aspect(..., adjustable='datalim') and "
1945+
"axis('equal') are not allowed when both axes "
1946+
"are shared. Try set_aspect(..., "
1947+
"adjustable='box').")
19461948

19471949
# If y is shared, then we are only allowed to change x, etc.
19481950
if shared_y:
@@ -2044,7 +2046,11 @@ def axis(self, *args, emit=True, **kwargs):
20442046
self.autoscale_view(tight=False)
20452047
# self.apply_aspect()
20462048
if s == 'equal':
2047-
self.set_aspect('equal', adjustable='datalim')
2049+
try:
2050+
self.set_aspect('equal', adjustable='datalim')
2051+
except RuntimeError:
2052+
raise RuntimeError("'equal' is not allowed on shared "
2053+
"axes, try 'scaled' instead.")
20482054
elif s == 'scaled':
20492055
self.set_aspect('equal', adjustable='box', anchor='C')
20502056
self.set_autoscale_on(False) # Req. by Mark Bakker

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.