def contour(self, X, Y, Z, levels=10, **kwargs): ''' Create a 3D contour plot. ========== ================================================ Argument Description ========== ================================================ *X*, *Y*, Data values as numpy.arrays *Z* *levels* Number of levels to use, defaults to 10. Can also be a tuple of specific levels. *extend3d* Whether to extend contour in 3D (default: False) *stride* Stride (step size) for extending contour ========== ================================================ Other keyword arguments are passed on to :func:`~matplotlib.axes.Axes.contour` ''' extend3d = kwargs.pop('extend3d', False) stride = kwargs.pop('stride', 5) nlevels = kwargs.pop('nlevels', 15) had_data = self.has_data() cset = Axes.contour(self, X, Y, Z, levels, **kwargs) if extend3d: self._3d_extend_contour(cset, stride) else: for z, linec in zip(cset.levels, cset.collections): art3d.line_collection_2d_to_3d(linec, z) self.auto_scale_xyz(X, Y, Z, had_data) return cset
def add_collection3d(self, col, zs=0, zdir='z'): ''' Add a 3d collection object to the plot. 2D collection types are converted to a 3D version by modifying the object and adding z coordinate information. Supported are: - PolyCollection - LineColleciton - PatchCollection ''' zvals = np.atleast_1d(zs) if len(zvals) > 0 : zsortval = min(zvals) else : zsortval = 0 # FIXME: Fairly arbitrary. Is there a better value? if type(col) is collections.PolyCollection: art3d.poly_collection_2d_to_3d(col, zs=zs, zdir=zdir) col.set_sort_zpos(zsortval) elif type(col) is collections.LineCollection: art3d.line_collection_2d_to_3d(col, zs=zs, zdir=zdir) col.set_sort_zpos(zsortval) elif type(col) is collections.PatchCollection: art3d.patch_collection_2d_to_3d(col, zs=zs, zdir=zdir) col.set_sort_zpos(zsortval) Axes.add_collection(self, col)
def add_contour_set(self, cset, extend3d=False, stride=5, zdir='z', offset=None): zdir = '-' + zdir if extend3d: self._3d_extend_contour(cset, stride) else: for z, linec in zip(cset.levels, cset.collections): if offset is not None: z = offset art3d.line_collection_2d_to_3d(linec, z, zdir=zdir)
def contour(self, X, Y, Z, *args, **kwargs): """ Create a 3D contour plot. ========== ================================================ Argument Description ========== ================================================ *X*, *Y*, Data values as numpy.arrays *Z* *extend3d* Whether to extend contour in 3D (default: False) *stride* Stride (step size) for extending contour *zdir* The direction to use: x, y or z (default) *offset* If specified plot a projection of the contour lines on this position in plane normal to zdir ========== ================================================ The positional and other keyword arguments are passed on to :func:`~matplotlib.axes.Axes.contour` Returns a :class:`~matplotlib.axes.Axes.contour` """ extend3d = kwargs.pop("extend3d", False) stride = kwargs.pop("stride", 5) zdir = kwargs.pop("zdir", "z") offset = kwargs.pop("offset", None) had_data = self.has_data() jX, jY, jZ = art3d.rotate_axes(X, Y, Z, zdir) cset = Axes.contour(self, jX, jY, jZ, *args, **kwargs) zdir = "-" + zdir if extend3d: self._3d_extend_contour(cset, stride) else: for z, linec in zip(cset.levels, cset.collections): if offset is not None: z = offset art3d.line_collection_2d_to_3d(linec, z, zdir=zdir) self.auto_scale_xyz(X, Y, Z, had_data) return cset
def contour(self, X, Y, Z, *args, **kwargs): ''' Create a 3D contour plot. ========== ================================================ Argument Description ========== ================================================ *X*, *Y*, Data values as numpy.arrays *Z* *extend3d* Whether to extend contour in 3D (default: False) *stride* Stride (step size) for extending contour *zdir* The direction to use: x, y or z (default) *offset* If specified plot a projection of the contour lines on this position in plane normal to zdir ========== ================================================ The positional and other keyword arguments are passed on to :func:`~matplotlib.axes.Axes.contour` Returns a :class:`~matplotlib.axes.Axes.contour` ''' extend3d = kwargs.pop('extend3d', False) stride = kwargs.pop('stride', 5) zdir = kwargs.pop('zdir', 'z') offset = kwargs.pop('offset', None) had_data = self.has_data() jX, jY, jZ = art3d.rotate_axes(X, Y, Z, zdir) cset = Axes.contour(self, jX, jY, jZ, *args, **kwargs) zdir = '-' + zdir if extend3d: self._3d_extend_contour(cset, stride) else: for z, linec in zip(cset.levels, cset.collections): if offset is not None: z = offset art3d.line_collection_2d_to_3d(linec, z, zdir=zdir) self.auto_scale_xyz(X, Y, Z, had_data) return cset
def add_collection3d(self, col, zs=0, zdir='z'): ''' Add a 3d collection object to the plot. 2D collection types are converted to a 3D version by modifying the object and adding z coordinate information. Supported are: - PolyCollection - LineColleciton - PatchCollection ''' if type(col) is collections.PolyCollection: art3d.poly_collection_2d_to_3d(col, zs=zs, zdir=zdir) col.set_sort_zpos(min(zs)) elif type(col) is collections.LineCollection: art3d.line_collection_2d_to_3d(col, zs=zs, zdir=zdir) col.set_sort_zpos(min(zs)) elif type(col) is collections.PatchCollection: art3d.patch_collection_2d_to_3d(col, zs=zs, zdir=zdir) col.set_sort_zpos(min(zs)) Axes.add_collection(self, col)