Exemplo n.º 1
0
        matplotlib color arg (all patches have same color), or a a
        sequence or rgba tuples; if it is a sequence the patches will
        cycle through the sequence

        ACCEPTS: matplotlib color arg or sequence of rgba tuples
        """
        self._edgecolors = _colors.colorConverter.to_rgba_array(c)

    def color(self, c):
        """
        Set the color(s) of the line collection.  c can be a
        matplotlib color arg (all patches have same color), or a a
        sequence or rgba tuples; if it is a sequence the patches will
        cycle through the sequence

        ACCEPTS: matplotlib color arg or sequence of rgba tuples
        """
        warnings.warn('LineCollection.color deprecated; use set_color instead')
        return self.set_color(c)

    def get_color(self):
        return self._edgecolors
    get_colors = get_color  # for compatibility with old versions


artist.kwdocd['Collection'] = patchstr = artist.kwdoc(Collection)
for k in ('QuadMesh', 'PolyCollection', 'BrokenBarHCollection', 'RegularPolyCollection',
          'StarPolygonCollection'):
    artist.kwdocd[k] = patchstr
artist.kwdocd['LineCollection'] = artist.kwdoc(LineCollection)
Exemplo n.º 2
0
        axes_class = Axes
    try:
        # Avoid creating two different instances of GeoAxesSubplot...
        # Only a temporary backcompat fix.  This should be removed in
        # 3.4
        return next(cls for cls in SubplotBase.__subclasses__()
                    if cls.__bases__ == (SubplotBase, axes_class))
    except StopIteration:
        return type("%sSubplot" % axes_class.__name__,
                    (SubplotBase, axes_class),
                    {'_axes_class': axes_class})


# This is provided for backward compatibility
Subplot = subplot_class_factory()


def _picklable_subplot_class_constructor(axes_class):
    """
    This stub class exists to return the appropriate subplot class when called
    with an axes class. This is purely to allow pickling of Axes and Subplots.
    """
    subplot_class = subplot_class_factory(axes_class)
    return subplot_class.__new__(subplot_class)


docstring.interpd.update(Axes=martist.kwdoc(Axes))
docstring.dedent_interpd(Axes.__init__)

docstring.interpd.update(Subplot=martist.kwdoc(Axes))
Exemplo n.º 3
0
    r.set_clip_on( False )
    r.update(props)
    r.draw(renderer)


def draw_bbox(bbox, renderer, color='k', trans=None):
    """
    This is a debug function to draw a rectangle around the bounding
    box returned by get_window_extent of an artist, to test whether
    the artist is returning the correct bbox
    """

    l,b,w,h = bbox.get_bounds()
    r = Rectangle(xy=(l,b),
                  width=w,
                  height=h,
                  edgecolor=color,
                  fill=False,
                  )
    if trans is not None: r.set_transform(trans)
    r.set_clip_on( False )
    r.draw(renderer)

artist.kwdocd['Patch'] = patchdoc = artist.kwdoc(Patch)

for k in ('Rectangle', 'Circle', 'RegularPolygon', 'Polygon', 'Wedge', 'Arrow',
          'FancyArrow', 'YAArrow', 'CirclePolygon', 'Ellipse'):
    artist.kwdocd[k] = patchdoc


Exemplo n.º 4
0
                 self._coordinates.shape[1],
                 2))
            coordinates = transform.transform(coordinates)
            coordinates = coordinates.reshape(self._coordinates.shape)
            transform = transforms.IdentityTransform()
        else:
            coordinates = self._coordinates
        if not transOffset.is_affine:
            offsets = transOffset.transform_non_affine(offsets)
            transOffset = transOffset.get_affine()
        gc = renderer.new_gc()
        self._set_gc_clip(gc)
        if self._shading == 'gouraud':
            triangles, colors = self.convert_mesh_to_triangles(
                self._meshWidth, self._meshHeight, coordinates)
            renderer.draw_gouraud_triangles(gc, triangles, colors, transform.frozen())
        else:
            renderer.draw_quad_mesh(
                gc, transform.frozen(), self._meshWidth, self._meshHeight,
                coordinates, offsets, transOffset, self.get_facecolor(),
                self._antialiased, self._showedges)
        gc.restore()
        renderer.close_group(self.__class__.__name__)
patchstr = artist.kwdoc(Collection)
for k in ('QuadMesh', 'PolyCollection', 'BrokenBarHCollection',
           'RegularPolyCollection', 'PathCollection',
          'StarPolygonCollection', 'PatchCollection',
          'CircleCollection', 'Collection',):
    docstring.interpd.update({k:patchstr})
docstring.interpd.update(LineCollection = artist.kwdoc(LineCollection))
Exemplo n.º 5
0
def draw_bbox(bbox, renderer, color="k", trans=None):
    """
    This is a debug function to draw a rectangle around the bounding
    box returned by get_window_extent of an artist, to test whether
    the artist is returning the correct bbox
    """

    l, b, w, h = bbox.get_bounds()
    r = Rectangle(xy=(l, b), width=w, height=h, edgecolor=color, fill=False)
    if trans is not None:
        r.set_transform(trans)
    r.set_clip_on(False)
    r.draw(renderer)


artist.kwdocd["Patch"] = patchdoc = artist.kwdoc(Patch)
for k in (
    "Rectangle",
    "Circle",
    "RegularPolygon",
    "Polygon",
    "Wedge",
    "Arrow",
    "FancyArrow",
    "YAArrow",
    "CirclePolygon",
    "Ellipse",
):
    artist.kwdocd[k] = patchdoc
Exemplo n.º 6
0
                return [0, 0, 0, 0]

            facecolors = [determine_facecolor(p) for p in patches]
            edgecolors = [p.get_edgecolor() for p in patches]
            linewidths = [p.get_linewidths() for p in patches]
            antialiaseds = [p.get_antialiased() for p in patches]

            Collection.__init__(
                self,
                edgecolors=edgecolors,
                facecolors=facecolors,
                linewidths=linewidths,
                linestyles="solid",
                antialiaseds=antialiaseds,
            )
        else:
            Collection.__init__(self, **kwargs)

        paths = [p.get_transform().transform_path(p.get_path()) for p in patches]

        self._paths = paths

    def get_paths(self):
        return self._paths


artist.kwdocd["Collection"] = patchstr = artist.kwdoc(Collection)
for k in ("QuadMesh", "PolyCollection", "BrokenBarHCollection", "RegularPolyCollection", "StarPolygonCollection"):
    artist.kwdocd[k] = patchstr
artist.kwdocd["LineCollection"] = artist.kwdoc(LineCollection)
Exemplo n.º 7
0
    figsize_min = np.array((4.0,2.0)) # min length for width/height
    figsize_max = np.array((16.0,16.0)) # max length for width/height
    #figsize_min = rcParams['figure.figsize_min']
    #figsize_max = rcParams['figure.figsize_max']

    # Extract the aspect ratio of the array
    if isarray:
        nr,nc = arg.shape[:2]
        arr_ratio = float(nr)/nc
    else:
        arr_ratio = float(arg)

    # Height of user figure defaults
    fig_height = rcParams['figure.figsize'][1]

    # New size for the figure, keeping the aspect ratio of the caller
    newsize = np.array((fig_height/arr_ratio,fig_height))

    # Sanity checks, don't drop either dimension below figsize_min
    newsize /= min(1.0,*(newsize/figsize_min))

    # Avoid humongous windows as well
    newsize /= max(1.0,*(newsize/figsize_max))

    # Finally, if we have a really funky aspect ratio, break it but respect
    # the min/max dimensions (we don't want figures 10 feet tall!)
    newsize = np.clip(newsize,figsize_min,figsize_max)
    return newsize

docstring.interpd.update(Figure=martist.kwdoc(Figure))
Exemplo n.º 8
0
class _PicklableSubplotClassConstructor(object):
    """
    This stub class exists to return the appropriate subplot
    class when __call__-ed with an axes class. This is purely to
    allow Pickling of Axes and Subplots.
    """
    def __call__(self, axes_class):
        # create a dummy object instance
        subplot_instance = _PicklableSubplotClassConstructor()
        subplot_class = subplot_class_factory(axes_class)
        # update the class to the desired subplot class
        subplot_instance.__class__ = subplot_class
        return subplot_instance


docstring.interpd.update(Axes=martist.kwdoc(Axes))
docstring.interpd.update(Subplot=martist.kwdoc(Axes))
"""
# this is some discarded code I was using to find the minimum positive
# data point for some log scaling fixes.  I realized there was a
# cleaner way to do it, but am keeping this around as an example for
# how to get the data out of the axes.  Might want to make something
# like this a method one day, or better yet make get_verts an Artist
# method

            minx, maxx = self.get_xlim()
            if minx<=0 or maxx<=0:
                # find the min pos value in the data
                xs = []
                for line in self.lines:
                    xs.extend(line.get_xdata(orig=False))
Exemplo n.º 9
0
        if self._shading == 'gouraud':
            triangles, colors = self.convert_mesh_to_triangles(
                self._meshWidth, self._meshHeight, coordinates)
            renderer.draw_gouraud_triangles(gc, triangles, colors,
                                            transform.frozen())
        else:
            renderer.draw_quad_mesh(gc, transform.frozen(), self._meshWidth,
                                    self._meshHeight,
                                    coordinates, offsets, transOffset,
                                    self.get_facecolor(), self._antialiased,
                                    self._showedges)
        gc.restore()
        renderer.close_group(self.__class__.__name__)


patchstr = artist.kwdoc(Collection)
for k in (
        'QuadMesh',
        'TriMesh',
        'PolyCollection',
        'BrokenBarHCollection',
        'RegularPolyCollection',
        'PathCollection',
        'StarPolygonCollection',
        'PatchCollection',
        'CircleCollection',
        'Collection',
):
    docstring.interpd.update({k: patchstr})
docstring.interpd.update(LineCollection=artist.kwdoc(LineCollection))
Exemplo n.º 10
0
            facecolors = [determine_facecolor(p) for p in patches]
            edgecolors = [p.get_edgecolor() for p in patches]
            linewidths = [p.get_linewidth() for p in patches]
            antialiaseds = [p.get_antialiased() for p in patches]

            Collection.__init__(self,
                                edgecolors=edgecolors,
                                facecolors=facecolors,
                                linewidths=linewidths,
                                linestyles='solid',
                                antialiaseds=antialiaseds)
        else:
            Collection.__init__(self, **kwargs)

        paths = [
            p.get_transform().transform_path(p.get_path()) for p in patches
        ]

        self._paths = paths

    def get_paths(self):
        return self._paths


artist.kwdocd['Collection'] = patchstr = artist.kwdoc(Collection)
for k in ('QuadMesh', 'PolyCollection', 'BrokenBarHCollection',
          'RegularPolyCollection', 'StarPolygonCollection', 'PatchCollection',
          'CircleCollection'):
    artist.kwdocd[k] = patchstr
artist.kwdocd['LineCollection'] = artist.kwdoc(LineCollection)
Exemplo n.º 11
0
    r.set_clip_on(False)
    r.update(props)
    r.draw(renderer)


def draw_bbox(bbox, renderer, color='k', trans=None):
    """
    This is a debug function to draw a rectangle around the bounding
    box returned by
    :meth:`~matplotlib.artist.Artist.get_window_extent` of an artist,
    to test whether the artist is returning the correct bbox.
    """

    l, b, w, h = bbox.get_bounds()
    r = Rectangle(
        xy=(l, b),
        width=w,
        height=h,
        edgecolor=color,
        fill=False,
    )
    if trans is not None: r.set_transform(trans)
    r.set_clip_on(False)
    r.draw(renderer)


artist.kwdocd['Patch'] = patchdoc = artist.kwdoc(Patch)
for k in ('Rectangle', 'Circle', 'RegularPolygon', 'Polygon', 'Wedge', 'Arrow',
          'FancyArrow', 'YAArrow', 'CirclePolygon', 'Ellipse', 'Arc'):
    artist.kwdocd[k] = patchdoc