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

Skip to content

Commit b79fea0

Browse files
committed
Let Axes3D share have_units with 2d axes.
plus some small cleanup to axes3d.
1 parent 59b5e0e commit b79fea0

File tree

3 files changed

+12
-28
lines changed

3 files changed

+12
-28
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
@@ -2036,7 +2036,7 @@ def _on_units_changed(self, scalex=False, scaley=False):
20362036
"""
20372037
Callback for processing changes to axis units.
20382038
2039-
Currently forces updates of data limits and view limits.
2039+
Currently requests updates of data limits and view limits.
20402040
"""
20412041
self.relim()
20422042
self._request_autoscale_view(scalex=scalex, scaley=scaley)

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 9 additions & 23 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)
@@ -328,7 +320,7 @@ def get_axis_position(self):
328320
def _on_units_changed(self, scalex=False, scaley=False, scalez=False):
329321
"""
330322
Callback for processing changes to axis units.
331-
323+
332324
Currently forces updates of data limits and view limits.
333325
"""
334326
self.relim()
@@ -1093,12 +1085,8 @@ def can_pan(self):
10931085
return False
10941086

10951087
def cla(self):
1096-
"""
1097-
Clear axes
1098-
"""
1099-
# Disabling mouse interaction might have been needed a long
1100-
# time ago, but I can't find a reason for it now - BVR (2012-03)
1101-
#self.disable_mouse_rotation()
1088+
# docstring inherited.
1089+
11021090
super().cla()
11031091
self.zaxis.cla()
11041092

@@ -1121,12 +1109,10 @@ def cla(self):
11211109
self.grid(rcParams['axes3d.grid'])
11221110

11231111
def disable_mouse_rotation(self):
1124-
"""Disable mouse button callbacks.
1125-
"""
1112+
"""Disable mouse button callbacks."""
11261113
# Disconnect the various events we set.
11271114
for cid in self._cids:
11281115
self.figure.canvas.mpl_disconnect(cid)
1129-
11301116
self._cids = []
11311117

11321118
def _button_press(self, event):

0 commit comments

Comments
 (0)