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

Skip to content

Commit f427d56

Browse files
committed
Add unit decorator to mplot3d
1 parent 07bf0d6 commit f427d56

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import matplotlib.docstring as docstring
3030
import matplotlib.scale as mscale
3131
import matplotlib.transforms as mtransforms
32+
import matplotlib.units as munits
3233
from matplotlib.axes import Axes, rcParams
3334
from matplotlib.colors import Normalize, LightSource
3435
from matplotlib.transforms import Bbox
@@ -609,6 +610,7 @@ def _determine_lims(self, xmin=None, xmax=None, *args, **kwargs):
609610
xmax += 0.05
610611
return (xmin, xmax)
611612

613+
@munits._accepts_units(convert_x=['left', 'right'])
612614
def set_xlim3d(self, left=None, right=None, emit=True, auto=False, **kw):
613615
"""
614616
Set 3D x limits.
@@ -626,9 +628,8 @@ def set_xlim3d(self, left=None, right=None, emit=True, auto=False, **kw):
626628
if right is None and cbook.iterable(left):
627629
left, right = left
628630

629-
self._process_unit_info(xdata=(left, right))
630-
left = self._validate_converted_limits(left, self.convert_xunits)
631-
right = self._validate_converted_limits(right, self.convert_xunits)
631+
self._validate_converted_limits(left)
632+
self._validate_converted_limits(right)
632633

633634
old_left, old_right = self.get_xlim()
634635
if left is None:
@@ -661,6 +662,7 @@ def set_xlim3d(self, left=None, right=None, emit=True, auto=False, **kw):
661662
return left, right
662663
set_xlim = set_xlim3d
663664

665+
@munits._accepts_units(convert_y=['bottom', 'top'])
664666
def set_ylim3d(self, bottom=None, top=None, emit=True, auto=False, **kw):
665667
"""
666668
Set 3D y limits.
@@ -678,9 +680,8 @@ def set_ylim3d(self, bottom=None, top=None, emit=True, auto=False, **kw):
678680
if top is None and cbook.iterable(bottom):
679681
bottom, top = bottom
680682

681-
self._process_unit_info(ydata=(bottom, top))
682-
bottom = self._validate_converted_limits(bottom, self.convert_yunits)
683-
top = self._validate_converted_limits(top, self.convert_yunits)
683+
self._validate_converted_limits(bottom)
684+
self._validate_converted_limits(top)
684685

685686
old_bottom, old_top = self.get_ylim()
686687
if bottom is None:
@@ -731,8 +732,10 @@ def set_zlim3d(self, bottom=None, top=None, emit=True, auto=False, **kw):
731732
bottom, top = bottom
732733

733734
self._process_unit_info(zdata=(bottom, top))
734-
bottom = self._validate_converted_limits(bottom, self.convert_zunits)
735-
top = self._validate_converted_limits(top, self.convert_zunits)
735+
bottom = self.convert_zunits(bottom)
736+
top = self.convert_zunits(top)
737+
self._validate_converted_limits(bottom)
738+
self._validate_converted_limits(top)
736739

737740
old_bottom, old_top = self.get_zlim()
738741
if bottom is None:

0 commit comments

Comments
 (0)