geopandas.GeoSeries.plot#

GeoSeries.plot(*args, **kwargs)[source]#

Plot a GeoSeries.

Generate a plot of a GeoSeries geometry with matplotlib.

Parameters:
sSeries

The GeoSeries to be plotted. Currently Polygon, MultiPolygon, LineString, MultiLineString, Point and MultiPoint geometries can be plotted.

cmapstr | Colormap (default None)

The name of a colormap recognized by matplotlib, or a matplotlib.colors.Colormap. Colors will be mapped to individual geometries along their order of appearance in the GeoSeries. Any colormap will work, but categorical colormaps are generally recommended. Examples of useful discrete colormaps include:

“tab10”, “tab20”, “Accent”, “Dark2”, “Paired”, “Pastel1”, “Set1”, “Set2”

colorstr, np.array, pd.Series (default None)

Color of the geometry. If specified as scalar matplotlib understands as a color (str, tuple or RGBA etc.), all objects will be colored uniformly. If specifies as array-like of the same length as GeoDataFrame, individual colors will be mapped to respective geometries..

axmatplotlib.axes.Axes (default None)

matplotlib.axes.Axes axes on which to draw the plot

figsizetuple of integers (default None)

Size of the resulting matplotlib.figure.Figure. If the argument ax is given explicitly, figsize is ignored.

aspect‘auto’, ‘equal’, None or float (default 'auto')

Set aspect of axis. If 'auto', the default aspect for map plots is 'equal'; if however data are not projected (coordinates are long/lat), the aspect is by default set to 1/cos(df_y * pi/180) with df_y the y coordinate of the middle of the GeoDataFrame (the mean of the y range of bounding box) so that a long/lat square appears square in the middle of the plot. This implies an Equirectangular projection. If None, the aspect of ax won’t be changed. It can also be set manually (float) as the ratio of y-unit to x-unit.

autolimbool (default True)

Update axes data limits to contain the new geometries.

tilesbool, str, xyzservices.TileProvider, os.PathLike, file-like, or rasterio.io.MemoryFile (default False)

Add contextual background tiles. Can be either a boolean, xyzservices.TileProvider, any string that can be resolved by xyzservices.providers.query_name(), URL, or a path to a local file. The placeholders for the XYZ in the URL need to be {x}, {y}, {z}, respectively. For local file paths, the file is read with rasterio and all bands are loaded into the basemap. The tiles are automatically warped to the CRS of the geometry. Note that this can result in suboptimal rendering. To avoid warping, geometry needs to be in EPSG:3857 (Web Mercator) or a CRS of the tiles if other projection is used. Default basemap when True follows the default of the underlying contextily.add_basemap(), which is OpenStreetMap Humanitarian.

attrstr (default None)

Attribution text passed to contextily.add_basemap() as attribution. When not provided, the default attribution of the selected tile source is used.

add_labelsbool (default True)

Use CRS metadata to label the axes.

**style_kwdsdict

Style options to be passed on to the actual plot function, such as edgecolor, facecolor, linewidth, markersize, alpha. These can be scalar, which are uniformly mapped to all geometries, or array-likes of the same length as GeoSeries, which are mapped to their respective geometries.

Returns:
axmatplotlib axes instance