#NEWLINE# def plot_dataframe( s , column = None , cmap = None , color = None , linewidth = 1.0 , categorical = False , legend = False , ax = None , scheme = None , k = 5 , vmin = None , vmax = None , figsize = None , **color_kwds ) : #NEWLINE# #INDENT# " Plot a GeoDataFrame\n\n        Generate a plot of a GeoDataFrame with matplotlib.  If a\n        column is specified, the plot coloring will be based on values\n        in that column.  Otherwise, a categorical plot of the\n        geometries in the `geometry` column will be generated.\n\n        Parameters\n        ----------\n\n        GeoDataFrame\n            The GeoDataFrame to be plotted.  Currently Polygon,\n            MultiPolygon, LineString, MultiLineString and Point\n            geometries can be plotted.\n\n        column : str (default None)\n            The name of the column to be plotted.\n\n        categorical : bool (default False)\n            If False, cmap will reflect numerical values of the\n            column being plotted.  For non-numerical columns (or if\n            column=None), this will be set to True.\n\n        cmap : str (default 'Set1')\n            The name of a colormap recognized by matplotlib.\n\n        color : str (default None)\n            If specified, all objects will be colored uniformly.\n\n        linewidth : float (default 1.0)\n            Line width for geometries.\n\n        legend : bool (default False)\n            Plot a legend (Experimental; currently for categorical\n            plots only)\n\n        ax : matplotlib.pyplot.Artist (default None)\n            axes on which to draw the plot\n\n        scheme : pysal.esda.mapclassify.Map_Classifier\n            Choropleth classification schemes (requires PySAL)\n\n        k   : int (default 5)\n            Number of classes (ignored if scheme is None)\n\n        vmin : None or float (default None)\n\n            Minimum value of cmap. If None, the minimum data value\n            in the column to be plotted is used.\n\n        vmax : None or float (default None)\n\n            Maximum value of cmap. If None, the maximum data value\n            in the column to be plotted is used.\n\n        figsize\n            Size of the resulting matplotlib.figure.Figure. If the argument\n            axes is given explicitly, figsize is ignored.\n\n        **color_kwds : dict\n            Color options to be passed on to the actual plot function\n\n        Returns\n        -------\n\n        matplotlib axes instance\n    " #NEWLINE# if ( 'colormap' in color_kwds ) : #NEWLINE# #INDENT# warnings . warn ( "'colormap' is deprecated, please use 'cmap' instead (for consistency with matplotlib)" , FutureWarning ) #NEWLINE# cmap = color_kwds . pop ( 'colormap' ) #NEWLINE# #UNINDENT# if ( 'axes' in color_kwds ) : #NEWLINE# #INDENT# warnings . warn ( "'axes' is deprecated, please use 'ax' instead (for consistency with pandas)" , FutureWarning ) #NEWLINE# ax = color_kwds . pop ( 'axes' ) #NEWLINE# #UNINDENT# import matplotlib.pyplot as plt #NEWLINE# from matplotlib.lines import Line2D #NEWLINE# from matplotlib.colors import Normalize #NEWLINE# from matplotlib import cm #NEWLINE# if ( column is None ) : #NEWLINE# #INDENT# return plot_series ( s . geometry , cmap = cmap , color = color , ax = ax , linewidth = linewidth , figsize = figsize , ** color_kwds ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( s [ column ] . dtype is np . dtype ( 'O' ) ) : #NEWLINE# #INDENT# categorical = True #NEWLINE# #UNINDENT# if categorical : #NEWLINE# #INDENT# if ( cmap is None ) : #NEWLINE# #INDENT# cmap = 'Set1' #NEWLINE# #UNINDENT# categories = list ( set ( s [ column ] . values ) ) #NEWLINE# categories . sort ( ) #NEWLINE# valuemap = dict ( [ ( k , v ) for ( v , k ) in enumerate ( categories ) ] ) #NEWLINE# values = [ valuemap [ k ] for k in s [ column ] ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# values = s [ column ] #NEWLINE# #UNINDENT# if ( scheme is not None ) : #NEWLINE# #INDENT# binning = __pysal_choro ( values , scheme , k = k ) #NEWLINE# values = binning . yb #NEWLINE# categorical = True #NEWLINE# binedges = ( [ binning . yb . min ( ) ] + binning . bins . tolist ( ) ) #NEWLINE# categories = [ '{0:.2f} - {1:.2f}' . format ( binedges [ i ] , binedges [ ( i + 1 ) ] ) for i in range ( ( len ( binedges ) - 1 ) ) ] #NEWLINE# #UNINDENT# cmap = norm_cmap ( values , cmap , Normalize , cm , vmin = vmin , vmax = vmax ) #NEWLINE# if ( ax is None ) : #NEWLINE# #INDENT# ( fig , ax ) = plt . subplots ( figsize = figsize ) #NEWLINE# ax . set_aspect ( 'equal' ) #NEWLINE# #UNINDENT# for ( geom , value ) in zip ( s . geometry , values ) : #NEWLINE# #INDENT# if ( color is None ) : #NEWLINE# #INDENT# col = cmap . to_rgba ( value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# col = color #NEWLINE# #UNINDENT# if ( ( geom . type == 'Polygon' ) or ( geom . type == 'MultiPolygon' ) ) : #NEWLINE# #INDENT# plot_multipolygon ( ax , geom , facecolor = col , linewidth = linewidth , ** color_kwds ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( geom . type == 'LineString' ) or ( geom . type == 'MultiLineString' ) ) : #NEWLINE# #INDENT# plot_multilinestring ( ax , geom , color = col , linewidth = linewidth , ** color_kwds ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( geom . type == 'Point' ) : #NEWLINE# #INDENT# plot_point ( ax , geom , color = col , ** color_kwds ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if legend : #NEWLINE# #INDENT# if categorical : #NEWLINE# #INDENT# patches = [ ] #NEWLINE# for ( value , cat ) in enumerate ( categories ) : #NEWLINE# #INDENT# patches . append ( Line2D ( [ 0 ] , [ 0 ] , linestyle = 'none' , marker = 'o' , alpha = color_kwds . get ( 'alpha' , 0.5 ) , markersize = 10 , markerfacecolor = cmap . to_rgba ( value ) ) ) #NEWLINE# #UNINDENT# ax . legend ( patches , categories , numpoints = 1 , loc = 'best' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise NotImplementedError #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# plt . draw ( ) #NEWLINE# return ax