Exemplo n.º 1
0
 def bar(self, left, height, zs=0, zdir='z', *args, **kwargs):
     '''
     Add 2D bar(s).
     ==========  ================================================
     Argument    Description
     ==========  ================================================
     *left*      The x coordinates of the left sides of the bars.
     *height*    The height of the bars.
     *zs*        Z coordinate of bars, if one value is specified
                 they will all be placed at the same z.
     *zdir*      Which direction to use as z ('x', 'y' or 'z')
                 when plotting a 2d set.
     ==========  ================================================
     Keyword arguments are passed onto :func:`~matplotlib.axes.Axes.bar`.
     Returns a :class:`~mpl_toolkits.mplot3d.art3d.Patch3DCollection`
     '''
     had_data = self.has_data()
     patches = Axes.bar(self, left, height, *args, **kwargs)
     if not cbook.iterable(zs):
         zs = np.ones(len(left))*zs
     verts = []
     verts_zs = []
     for p, z in zip(patches, zs):
         vs = p.get_verts()
         verts += vs.tolist()
         verts_zs += [z] * len(vs)
         art3d.patch_2d_to_3d(p, zs, zdir)
         if 'alpha' in kwargs:
             p.set_alpha(kwargs['alpha'])
     xs, ys = zip(*verts)
     xs, ys, verts_zs = art3d.juggle_axes(xs, ys, verts_zs, zdir)
     self.auto_scale_xyz(xs, ys, verts_zs, had_data)
     return patches
Exemplo n.º 2
0
    def bar(self, left, height, zs=0, zdir='z', *args, **kwargs):
        '''
        Add 2D bar(s).

        ==========  ================================================
        Argument    Description
        ==========  ================================================
        *left*      The x coordinates of the left sides of the bars.
        *height*    The height of the bars.
        *zs*        Z coordinate of bars, if one value is specified
                    they will all be placed at the same z.
        *zdir*      Which direction to use as z ('x', 'y' or 'z')
                    when plotting a 2d set.
        ==========  ================================================

        Keyword arguments are passed onto :func:`~matplotlib.axes.Axes.bar`.

        Returns a :class:`~mpl_toolkits.mplot3d.art3d.Patch3DCollection`
        '''

        had_data = self.has_data()

        patches = Axes.bar(self, left, height, *args, **kwargs)

        if not cbook.iterable(zs):
            zs = np.ones(len(left)) * zs

        verts = []
        verts_zs = []
        for p, z in zip(patches, zs):
            vs = art3d.get_patch_verts(p)
            verts += vs.tolist()
            verts_zs += [z] * len(vs)
            art3d.patch_2d_to_3d(p, zs, zdir)
            if 'alpha' in kwargs:
                p.set_alpha(kwargs['alpha'])

        xs, ys = zip(*verts)
        xs, ys, verts_zs = art3d.juggle_axes(xs, ys, verts_zs, zdir)
        self.auto_scale_xyz(xs, ys, verts_zs, had_data)

        return patches