pygmt.Figure.choropleth
- Figure.choropleth(data, column, cmap=True, **kwargs)
Plot a choropleth map.
This method is a thin wrapper around
pygmt.Figure.plotthat sets the appropriate parameters for creating a choropleth map by filling polygons based on values in a specified data column. It requires the input data to be a geo-like Python object that implements__geo_interface__(e.g. ageopandas.GeoDataFrame), or a OGR_GMT file contaning the geometry and data to plot.- Parameters:
data (
GeoDataFrame|str|PathLike) – A geo-like Python object which implements__geo_interface__(e.g. ageopandas.GeoDataFrameorshapely.geometry), or a OGR_GMT file containing the geometry and data to plot.column (
str) – The name of the data column to use for the fill.cmap (
str|bool, default:True) – The CPT to use for filling the polygons. If set toTrue, the current CPT will be used.**kwargs – Additional keyword arguments passed to
pygmt.Figure.plot.
Examples
>>> import geopandas as gpd >>> import pygmt >>> gdf = gpd.read_file( ... "https://geodacenter.github.io/data-and-lab/data/airbnb.zip" ... ) >>> fig = pygmt.Figure() >>> pygmt.makecpt( ... cmap="acton", ... series=[gdf["population"].min(), gdf["population"].max(), 10], ... continuous=True, ... reverse=True, ... ) >>> fig.choropleth(gdf, column="population", pen="0.3p,gray10") >>> fig.colorbar(frame=True) >>> fig.show()