Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions mapclassify/tests/test_value_by_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import matplotlib.pyplot as plt
import pytest
from matplotlib.testing.decorators import image_comparison
from packaging.version import Version

from mapclassify import shift_colormap, truncate_colormap, vba_choropleth

# see gh#305
GPD_GT_113 = Version(geopandas.__version__) > Version("1.1.3")


class TestValueByAlphaChoropleth:
def setup_method(self):
Expand Down Expand Up @@ -129,3 +133,11 @@ def test_legend_kwargs(self):

assert isinstance(fig, matplotlib.figure.Figure)
assert isinstance(ax, matplotlib.axes.Axes)

@pytest.mark.skipif(not GPD_GT_113, reason="See GH#305")
@image_comparison(["crs_labels"], **pytest.image_comp_kws)
def test_crs_labels(self):
fig, ax = vba_choropleth(self.x, self.y, self.gdf, axis_labels=True)

assert isinstance(fig, matplotlib.figure.Figure)
assert isinstance(ax, matplotlib.axes.Axes)
13 changes: 11 additions & 2 deletions mapclassify/value_by_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def vba_choropleth(
legend=False,
legend_kwargs=None,
min_alpha=0.2,
axis_labels=False,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we wait until this is resolved in geopandas? If we're adding a keyword there, we will want it to be the same here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, absolutely. I will convert to draft. I was under the impression that there would probably not be a keyword added upstream.

):
"""Generate Value by Alpha Choropleth plots.

Expand Down Expand Up @@ -91,13 +92,17 @@ def vba_choropleth(
Keyword arguments for the legend.
min_alpha : float = 0.2
Minimum alpha threshold to prevent fully transparent masking.
axis_labels : bool = False
Remove CRS unit axis labels from the returned ``ax``. This retains default
behavior in ``mapclassify`` and only has an affect when ``geopandas>v1.1.3``
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
behavior in ``mapclassify`` and only has an affect when ``geopandas>v1.1.3``
behavior in ``mapclassify`` and only has an affect when ``geopandas>=v1.2``

There might be 1.1.4 which will not contain new plotting.

is installed.

Returns
-------
fig : matplotlip Figure instance
Figure of Value by Alpha choropleth
Figure of Value by Alpha choropleth.
ax : matplotlib Axes instance
Axes in which the figure is plotted
Axes in which the figure is plotted.

Examples
--------
Expand Down Expand Up @@ -206,6 +211,10 @@ def vba_choropleth(
)
gdf.plot(color=rgba, ax=ax)

if not axis_labels:
ax.set_xlabel("")
ax.set_ylabel("")
Comment on lines +214 to +216
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, if this is going to be solved on geopandas side, we would just want to pass the keyword.


if legend:
left, bottom, width, height = [0, 0.5, 0.2, 0.2]
ax2 = fig.add_axes([left, bottom, width, height])
Expand Down
Loading