Skip to content

Commit ec80e48

Browse files
committed
Add units kwarg to 3D (x,y,z)lim
1 parent 657ad7d commit ec80e48

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

+28-4
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,12 @@ def set_zlim3d(self, bottom=None, top=None, emit=True, auto=False,
769769
return bottom, top
770770
set_zlim = set_zlim3d
771771

772-
def get_xlim3d(self):
772+
def get_xlim3d(self, units=True):
773+
if units:
774+
return self._convert_back_lim(
775+
self.xy_viewLim.intervalx, self.xaxis)
773776
return tuple(self.xy_viewLim.intervalx)
777+
774778
get_xlim3d.__doc__ = maxes.Axes.get_xlim.__doc__
775779
get_xlim = get_xlim3d
776780
if get_xlim.__doc__ is not None:
@@ -779,8 +783,12 @@ def get_xlim3d(self):
779783
This function now correctly refers to the 3D x-limits
780784
"""
781785

782-
def get_ylim3d(self):
786+
def get_ylim3d(self, units=True):
787+
if units:
788+
return self._convert_back_lim(
789+
self.xy_viewLim.intervaly, self.yaxis)
783790
return tuple(self.xy_viewLim.intervaly)
791+
784792
get_ylim3d.__doc__ = maxes.Axes.get_ylim.__doc__
785793
get_ylim = get_ylim3d
786794
if get_ylim.__doc__ is not None:
@@ -789,8 +797,24 @@ def get_ylim3d(self):
789797
This function now correctly refers to the 3D y-limits.
790798
"""
791799

792-
def get_zlim3d(self):
793-
'''Get 3D z limits.'''
800+
def get_zlim3d(self, units=True):
801+
'''
802+
Get 3D z limits.
803+
804+
Parameters
805+
----------
806+
units : bool, optional
807+
If *True*, return limits with units attached.
808+
809+
Returns
810+
-------
811+
zlimits : tuple
812+
Returns the current z-axis limits as the tuple
813+
``(z0, z1)``.
814+
'''
815+
if units:
816+
return self._convert_back_lim(
817+
self.zz_viewLim.intervalx, self.zaxis)
794818
return tuple(self.zz_viewLim.intervalx)
795819
get_zlim = get_zlim3d
796820

0 commit comments

Comments
 (0)