Skip to content

Commit

Permalink
update axis method in 3D axes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaqiang committed Jun 2, 2023
1 parent 81c824e commit 7766047
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 22 deletions.
4 changes: 1 addition & 3 deletions meteoinfo-lab/milconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surfc_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh\meshc_peaks.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\test_shaperead-2.py"/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/>
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surfc_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh\meshc_peaks.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\map\test_shaperead-2.py"/>
</RecentFiles>
</File>
<Font>
<TextFont FontName="YaHei Consolas Hybrid" FontSize="14"/>
</Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
<Startup MainFormLocation="-7,0" MainFormSize="1383,767"/>
</MeteoInfo>
Binary file modified meteoinfo-lab/pylib/mipylib/plotlib/_axes3d$py.class
Binary file not shown.
109 changes: 90 additions & 19 deletions meteoinfo-lab/pylib/mipylib/plotlib/_axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,26 +288,97 @@ def set_zlim(self, zmin, zmax):
zmax = miutil.date2num(zmax)
self._axes.setZMinMax(zmin, zmax)

def axis(self, limits):
"""
Sets the min and max of the x,y, axes, with ``[xmin, xmax, ymin, ymax, zmin, zmax]`` .
:param limits: (*list*) Min and max of the x,y,z axes.
"""
if len(limits) == 6:
xmin = limits[0]
xmax = limits[1]
ymin = limits[2]
ymax = limits[3]
zmin = limits[4]
zmax = limits[5]
extent = Extent3D(xmin, xmax, ymin, ymax, zmin, zmax)
self._axes.setDrawExtent(extent)
self._axes.setAxesExtent(extent.clone())
return True
def set_axis_on(self):
"""
Set all axis visible.
"""
self._axes.setDrawBase(True)
self._axes.setBoxed(True)
self._axes.setDisplayXY(True)
self._axes.setDisplayZ(True)

def set_axis_off(self):
"""
Set all axis not visible.
"""
self._axes.setDrawBase(False)
self._axes.setBoxed(False)
self._axes.setDisplayXY(False)
self._axes.setDisplayZ(False)

def axis(self, arg=None, **kwargs):
"""
Convenience method to get or set some axis properties.
Call signatures::
xmin, xmax, ymin, ymax = axis()
xmin, xmax, ymin, ymax = axis([xmin, xmax, ymin, ymax])
xmin, xmax, ymin, ymax = axis(option)
xmin, xmax, ymin, ymax = axis(**kwargs)
Parameters
----------
xmin, xmax, ymin, ymax, zmin, zmax : float, optional
The axis limits to be set. This can also be achieved using ::
ax.set(xlim=(xmin, xmax), ylim=(ymin, ymax), zlim=(zmin, zmax))
option : bool or str
If a bool, turns axis lines and labels on or off. If a string,
possible values are:
======== ==========================================================
Value Description
======== ==========================================================
'on' Turn on axis lines and labels. Same as ``True``.
'off' Turn off axis lines and labels. Same as ``False``.
'equal' Set equal scaling (i.e., make circles circular) by
changing axis limits. This is the same as
``ax.set_aspect('equal', adjustable='datalim')``.
Explicit data limits may not be respected in this case.
'scaled' Set equal scaling (i.e., make circles circular) by
changing dimensions of the plot box. This is the same as
``ax.set_aspect('equal', adjustable='box', anchor='C')``.
Additionally, further autoscaling will be disabled.
'tight' Set limits just large enough to show all data, then
disable further autoscaling.
'auto' Automatic scaling (fill plot box with data).
'image' 'scaled' with axis limits equal to data limits.
'square' Square plot; similar to 'scaled', but initially forcing
``xmax-xmin == ymax-ymin``.
======== ==========================================================
Returns
-------
xmin, xmax, ymin, ymax, zmin, zmax : float
The axis limits.
"""
if isinstance(arg, (str, bool)):
if arg is True:
arg = 'on'
if arg is False:
arg = 'off'
arg = arg.lower()
if arg == 'on':
self.set_axis_on()
elif arg == 'off':
self.set_axis_off()
elif arg in ['auto', 'equal']:
self.set_aspect(arg)
else:
raise ValueError("Unrecognized string {} to axis; "
"try 'on' or 'off'".format(arg))
else:
print('The limits parameter must be a list with 6 elements: xmin, xmax, ymin, ymax, zmin, zmax!')
return None
if arg is not None:
try:
xmin, xmax, ymin, ymax, zmin, zmax = arg
except (TypeError, ValueError) as err:
raise TypeError('the first argument to axis() must be an '
'iterable of the form '
'[xmin, xmax, ymin, ymax, zmin, zmax]')
self.set_xlim(xmin, xmax)
self.set_ylim(ymin, ymax)
self.set_zlim(zmin, zmax)

return self.get_xlim() + self.get_ylim() + self.get_zlim()

def set_zlabel(self, label, **kwargs):
"""
Expand Down

0 comments on commit 7766047

Please sign in to comment.