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

Skip to content

Commit 20f0815

Browse files
authored
Merge pull request #14576 from anntzer/3dunits
Let Axes3D share have_units, _on_units_changed with 2d axes.
2 parents dce1871 + c618f26 commit 20f0815

File tree

3 files changed

+11
-27
lines changed

3 files changed

+11
-27
lines changed

lib/matplotlib/artist.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,9 @@ def remove(self):
161161
# TODO: add legend support
162162

163163
def have_units(self):
164-
"""Return *True* if units are set on the *x* or *y* axes."""
164+
"""Return *True* if units are set on any axis."""
165165
ax = self.axes
166-
if ax is None or ax.xaxis is None:
167-
return False
168-
return ax.xaxis.have_units() or ax.yaxis.have_units()
166+
return ax and any(axis.have_units() for axis in ax._get_axis_list())
169167

170168
def convert_xunits(self, x):
171169
"""

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ def _on_units_changed(self, scalex=False, scaley=False):
19691969
"""
19701970
Callback for processing changes to axis units.
19711971
1972-
Currently forces updates of data limits and view limits.
1972+
Currently requests updates of data limits and view limits.
19731973
"""
19741974
self.relim()
19751975
self._request_autoscale_view(scalex=scalex, scaley=scaley)

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Module containing Axes3D, an object which can plot 3D objects on a
1010
2D matplotlib figure.
1111
"""
12+
1213
from collections import defaultdict
1314
from functools import reduce
1415
import math
@@ -140,14 +141,6 @@ def set_axis_on(self):
140141
self._axis3don = True
141142
self.stale = True
142143

143-
def have_units(self):
144-
"""
145-
Return *True* if units are set on the *x*, *y*, or *z* axes
146-
147-
"""
148-
return (self.xaxis.have_units() or self.yaxis.have_units() or
149-
self.zaxis.have_units())
150-
151144
def convert_zunits(self, z):
152145
"""
153146
For artists in an axes, if the zaxis has units support,
@@ -187,11 +180,10 @@ def _process_unit_info(self, xdata=None, ydata=None, zdata=None,
187180
def set_top_view(self):
188181
# this happens to be the right view for the viewing coordinates
189182
# moved up and to the left slightly to fit labels and axes
190-
xdwl = (0.95/self.dist)
191-
xdw = (0.9/self.dist)
192-
ydwl = (0.95/self.dist)
193-
ydw = (0.9/self.dist)
194-
183+
xdwl = 0.95 / self.dist
184+
xdw = 0.9 / self.dist
185+
ydwl = 0.95 / self.dist
186+
ydw = 0.9 / self.dist
195187
# This is purposely using the 2D Axes's set_xlim and set_ylim,
196188
# because we are trying to place our viewing pane.
197189
super().set_xlim(-xdwl, xdw, auto=None)
@@ -1088,12 +1080,8 @@ def can_pan(self):
10881080
return False
10891081

10901082
def cla(self):
1091-
"""
1092-
Clear axes
1093-
"""
1094-
# Disabling mouse interaction might have been needed a long
1095-
# time ago, but I can't find a reason for it now - BVR (2012-03)
1096-
#self.disable_mouse_rotation()
1083+
# docstring inherited.
1084+
10971085
super().cla()
10981086
self.zaxis.cla()
10991087

@@ -1116,12 +1104,10 @@ def cla(self):
11161104
self.grid(rcParams['axes3d.grid'])
11171105

11181106
def disable_mouse_rotation(self):
1119-
"""Disable mouse button callbacks.
1120-
"""
1107+
"""Disable mouse button callbacks."""
11211108
# Disconnect the various events we set.
11221109
for cid in self._cids:
11231110
self.figure.canvas.mpl_disconnect(cid)
1124-
11251111
self._cids = []
11261112

11271113
def _button_press(self, event):

0 commit comments

Comments
 (0)