diff --git a/meteoinfo-lab/milconfig.xml b/meteoinfo-lab/milconfig.xml index d9132b12..f166b8de 100644 --- a/meteoinfo-lab/milconfig.xml +++ b/meteoinfo-lab/milconfig.xml @@ -23,14 +23,12 @@ - - @@ -38,5 +36,5 @@
- + diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/_axes3d$py.class b/meteoinfo-lab/pylib/mipylib/plotlib/_axes3d$py.class index b5453af8..d5fe6bae 100644 Binary files a/meteoinfo-lab/pylib/mipylib/plotlib/_axes3d$py.class and b/meteoinfo-lab/pylib/mipylib/plotlib/_axes3d$py.class differ diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/_axes3d.py b/meteoinfo-lab/pylib/mipylib/plotlib/_axes3d.py index 685f9d1e..bee90e94 100644 --- a/meteoinfo-lab/pylib/mipylib/plotlib/_axes3d.py +++ b/meteoinfo-lab/pylib/mipylib/plotlib/_axes3d.py @@ -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): """