From cba7e2f5fac50e9e14ebc5f7a614efbf4a4e3177 Mon Sep 17 00:00:00 2001 From: Nicholas Tan Date: Sat, 8 Jun 2024 15:48:51 +1000 Subject: [PATCH] BUG: fix kdeplot to allow use of fill=True after seaborn updates --- geoplot/geoplot.py | 2 +- tests/test_geoplot.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/test_geoplot.py diff --git a/geoplot/geoplot.py b/geoplot/geoplot.py index f950135..5094d42 100644 --- a/geoplot/geoplot.py +++ b/geoplot/geoplot.py @@ -1304,7 +1304,7 @@ def draw(self): sns.kdeplot( x=pd.Series([p.x for p in self.df.geometry]), y=pd.Series([p.y for p in self.df.geometry]), - transform=ccrs.PlateCarree(), ax=ax, **self.kwargs + transform=ccrs.PlateCarree()._as_mpl_transform(ax), ax=ax, **self.kwargs ) else: sns.kdeplot( diff --git a/tests/test_geoplot.py b/tests/test_geoplot.py new file mode 100644 index 0000000..b361893 --- /dev/null +++ b/tests/test_geoplot.py @@ -0,0 +1,14 @@ +import geopandas as gpd +import geoplot as gplt +import geoplot.crs as gcrs +import matplotlib.pyplot as plt +import pytest + + +def test_kdeplot_projection_when_shade_true(): + boston_airbnb_listings = gpd.read_file(gplt.datasets.get_path('boston_airbnb_listings')) + + ax = gplt.kdeplot( + boston_airbnb_listings, cmap='viridis', projection=gcrs.WebMercator(), figsize=(12, 12), + fill=True + ) \ No newline at end of file