Example #1
0
 def add_contourf_set(self, cset, zdir='z', offset=None) :
     zdir = '-' + zdir
     for z, linec in zip(cset.levels, cset.collections) :
         if offset is not None :
             z = offset
         art3d.poly_collection_2d_to_3d(linec, z, zdir=zdir)
         linec.set_sort_zpos(z)
Example #2
0
    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)
Example #3
0
 def contourf(self, X, Y, Z, *args, **kwargs):
     '''
     Plot filled 3D contours.
     *X*, *Y*, *Z*: data points.
     Keyword arguments are passed on to
     :func:`~matplotlib.axes.Axes.contour`
     '''
     had_data = self.has_data()
     cset = Axes.contourf(self, X, Y, Z, *args, **kwargs)
     levels = cset.levels
     colls = cset.collections
     for z1, z2, linec in zip(levels, levels[1:], colls):
         art3d.poly_collection_2d_to_3d(linec, z1)
         linec.set_sort_zpos(z1)
     self.auto_scale_xyz(X, Y, Z, had_data)
     return cset
Example #4
0
 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)
Example #5
0
    def contourf(self, X, Y, Z, *args, **kwargs):
        '''
        Plot filled 3D contours.

        *X*, *Y*, *Z*: data points.

        Keyword arguments are passed on to
        :func:`~matplotlib.axes.Axes.contour`
        '''

        had_data = self.has_data()

        cset = Axes.contourf(self, X, Y, Z, *args, **kwargs)
        levels = cset.levels
        colls = cset.collections
        for z1, z2, linec in zip(levels, levels[1:], colls):
            art3d.poly_collection_2d_to_3d(linec, z1)
            linec.set_sort_zpos(z1)

        self.auto_scale_xyz(X, Y, Z, had_data)
        return cset
Example #6
0
    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)