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.
- cmap
str|Colormap(defaultNone) 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”
- color
str,np.array,pd.Series(defaultNone) Color of the geometry. If specified as scalar matplotlib understands as a color (
str,tupleor 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..- ax
matplotlib.axes.Axes(defaultNone) matplotlib.axes.Axesaxes on which to draw the plot- figsize
tupleof integers (default None) Size of the resulting
matplotlib.figure.Figure. If the argumentaxis given explicitly,figsizeis ignored.- aspect‘auto’, ‘equal’,
Noneorfloat(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 to1/cos(df_y * pi/180)withdf_ythe 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. IfNone, the aspect ofaxwon’t be changed. It can also be set manually (float) as the ratio of y-unit to x-unit.- autolim
bool(defaultTrue) 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 byxyzservices.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 underlyingcontextily.add_basemap(), which is OpenStreetMap Humanitarian.- attrstr (default None)
Attribution text passed to
contextily.add_basemap()asattribution. 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