shapelib/matplot.py
def geom_to_fig(geom, xrange=None, yrange=None, axis_visible=True,
                patchkws={}, aspect=1, linewidth=0.01, fig=None):
    """
    convert a shapely geometry to a matplotlib figure

    If xrange and yrange are given, use them.
    If not, the bounds of the geometry are used

    xrange: a number (xmax) or a tuple (xmin, xmax) defining the range to plot
            in the x coord
    yrange: the same in the y coord. If these are not given, they are deduced
            from the coordinates of the geometry
    axis_visible: show the axis and labels
    patchkws: passed as kws to descartes.PolygonPatch
    aspect: parameter passed to axis.set_aspect (possible values: 'auto',
            or a number defining the ratio y/x)
    fig: used internally when called recursively for multi-geometries

    NB: This function relies on functionality provided by `descartes`
    (https://bitbucket.org/sgillies/descartes/)
    """
    try:
        import descartes
    except ImportError:
        raise ImportError("descartes is needed to plot geometries")
    x0, y0, x1, y1 = util.geom_getbounds(geom, xrange, yrange)
    if fig is None:
        #fig = pyplot.figure(1, figsize=(xsize, ysize))
        fig = pyplot.figure()
        ax = fig.add_subplot(111)
    else:
        ax = fig.gca()
    if isinstance(geom, Polygon):
        p = geom.__geo_interface__
    else:
        geom0 = geom.buffer(linewidth)
        if isinstance(geom0, Polygon):
            p = geom0.__geo_interface__
        else:
            for subgeom in geom.geoms:
                fig = geom_to_fig(subgeom, xrange=(x0, x1), yrange=(y0, y1),
                                  axis_visible=axis_visible, patchkws=patchkws,
                                  aspect=aspect, fig=fig)
            return fig
    if not axis_visible:
        ax.get_yaxis().set_visible(False)
        ax.get_xaxis().set_visible(False)
        ax.axis('off')
    ax.set_xlim(x0, x1)
    ax.set_ylim(y0, y1)
    ax.set_aspect(aspect)
    pa = descartes.PolygonPatch(p, **patchkws)
    ax.add_patch(pa)
    return fig

    convert a shapely geometry to a matplotlib figure

    If xrange and yrange are given, use them.
    If not, the bounds of the geometry are used

    xrange: a number (xmax) or a tuple (xmin, xmax) defining the range to plot
            in the x coord
    yrange: the same in the y coord. If these are not given, they are deduced
            from the coordinates of the geometry
    axis_visible: show the axis and labels
    patchkws: passed as kws to descartes.PolygonPatch
    aspect: parameter passed to axis.set_aspect (possible values: 'auto',
            or a number defining the ratio y/x)
    fig: used internally when called recursively for multi-geometries

    NB: This function relies on functionality provided by `descartes`
    (https://bitbucket.org/sgillies/descartes/)
    
convert a shapely geometry to a matplotlib figure
If xrange and yrange are given, use them.
If not, the bounds of the geometry are used

a number (xmax) or a tuple (xmin, xmax) defining the range to plot
in the x coord
yrange: the same in the y coord.

This function relies on functionality provided by `descartes`
convert a shapely geometry to a matplotlib figure If xrange and yrange are given use them . If not the bounds of the geometry are used a number ( xmax ) or a tuple ( xmin xmax ) defining the range to plot in the x coord yrange : the same in the y coord . This function relies on functionality provided by ` descartes `
def geom_to_fig(geom, xrange=None, yrange=None, axis_visible=True,
                patchkws={}, aspect=1, linewidth=0.01, fig=None):
    try:
        import descartes
    except ImportError:
        raise ImportError("descartes is needed to plot geometries")
    x0, y0, x1, y1 = util.geom_getbounds(geom, xrange, yrange)
    if fig is None:
        fig = pyplot.figure()
        ax = fig.add_subplot(111)
    else:
        ax = fig.gca()
    if isinstance(geom, Polygon):
        p = geom.__geo_interface__
    else:
        geom0 = geom.buffer(linewidth)
        if isinstance(geom0, Polygon):
            p = geom0.__geo_interface__
        else:
            for subgeom in geom.geoms:
                fig = geom_to_fig(subgeom, xrange=(x0, x1), yrange=(y0, y1),
                                  axis_visible=axis_visible, patchkws=patchkws,
                                  aspect=aspect, fig=fig)
            return fig
    if not axis_visible:
        ax.get_yaxis().set_visible(False)
        ax.get_xaxis().set_visible(False)
        ax.axis('off')
    ax.set_xlim(x0, x1)
    ax.set_ylim(y0, y1)
    ax.set_aspect(aspect)
    pa = descartes.PolygonPatch(p, **patchkws)
    ax.add_patch(pa)
    return fig
def geom_to_fig ( geom , xrange = None , yrange = None , axis_visible = True , patchkws = { } , aspect = 1 , linewidth = 0.01 , fig = None ) : try : import descartes except ImportError : raise ImportError ( "descartes is needed to plot geometries" ) x0 , y0 , x1 , y1 = util . geom_getbounds ( geom , xrange , yrange ) if fig is None : fig = pyplot . figure ( ) ax = fig . add_subplot ( 111 ) else : ax = fig . gca ( ) if isinstance ( geom , Polygon ) : p = geom . __geo_interface__ else : geom0 = geom . buffer ( linewidth ) if isinstance ( geom0 , Polygon ) : p = geom0 . __geo_interface__ else : for subgeom in geom . geoms : fig = geom_to_fig ( subgeom , xrange = ( x0 , x1 ) , yrange = ( y0 , y1 ) , axis_visible = axis_visible , patchkws = patchkws , aspect = aspect , fig = fig ) return fig if not axis_visible : ax . get_yaxis ( ) . set_visible ( False ) ax . get_xaxis ( ) . set_visible ( False ) ax . axis ( 'off' ) ax . set_xlim ( x0 , x1 ) ax . set_ylim ( y0 , y1 ) ax . set_aspect ( aspect ) pa = descartes . PolygonPatch ( p , ** patchkws ) ax . add_patch ( pa ) return fig
convert a shapely geometry to a matplotlib figure
If xrange and yrange are given, use them.
convert a shapely geometry to a matplotlib figure If xrange and yrange are given use them .
"""
    convert a shapely geometry to a matplotlib figure

    If xrange and yrange are given, use them.
    If not, the bounds of the geometry are used

    xrange: a number (xmax) or a tuple (xmin, xmax) defining the range to plot
            in the x coord
    yrange: the same in the y coord. If these are not given, they are deduced
            from the coordinates of the geometry
    axis_visible: show the axis and labels
    patchkws: passed as kws to descartes.PolygonPatch
    aspect: parameter passed to axis.set_aspect (possible values: 'auto',
            or a number defining the ratio y/x)
    fig: used internally when called recursively for multi-geometries

    NB: This function relies on functionality provided by `descartes`
    (https://bitbucket.org/sgillies/descartes/)
    """ #fig = pyplot.figure(1, figsize=(xsize, ysize))
geom
xrange
yrange
axis_visible
patchkws
aspect
linewidth
fig