Skip to content

Commit 5a4f58a

Browse files
committed
Add Figure.choropleth to plot choropleth maps
1 parent c783a79 commit 5a4f58a

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

pygmt/figure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ def _repr_html_(self):
517517

518518
from pygmt.src import ( # type: ignore [misc]
519519
basemap,
520+
choropleth,
520521
coast,
521522
colorbar,
522523
contour,

pygmt/src/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pygmt.src.basemap import basemap
66
from pygmt.src.binstats import binstats
77
from pygmt.src.blockm import blockmean, blockmedian, blockmode
8+
from pygmt.src.choropleth import choropleth
89
from pygmt.src.coast import coast
910
from pygmt.src.colorbar import colorbar
1011
from pygmt.src.config import config

pygmt/src/choropleth.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
choropleth - Plot a choropleth map.
3+
"""
4+
5+
6+
def choropleth(self, data, fillcol: str, **kwargs):
7+
"""
8+
Plot a choropleth map.
9+
10+
Parameters
11+
----------
12+
data : :class:`geopandas.GeoDataFrame`
13+
The geopandas dataframe containing the geometry and data to plot.
14+
fillcol
15+
The column name of the data to use for the fill.
16+
"""
17+
self.plot(
18+
data=data,
19+
close=True,
20+
fill="+z",
21+
aspatial=f"Z={fillcol}",
22+
**kwargs,
23+
)

0 commit comments

Comments
 (0)