Skip to content

VBA - axis labels via geopandas add_labels (supersedes #306) - #323

Open
sjsrey wants to merge 4 commits into
pysal:mainfrom
sjsrey:GH305_vba_add_labels
Open

sjsrey wants to merge 4 commits into
pysal:mainfrom
sjsrey:GH305_vba_add_labels

Conversation

@sjsrey

@sjsrey sjsrey commented Oct 14, 2026

Copy link
Copy Markdown
Member

This PR

Changes on top of #306:

  • vba_choropleth passes add_labels=axis_labels to GeoDataFrame.plot() when geopandas>=1.2.0; older versions never add axis labels, so nothing is passed there. The manual set_xlabel("")/set_ylabel("") is dropped.
  • version check uses importlib.metadata (no runtime dependency on packaging)
  • label test gated on geopandas>=1.2.0 (the previous >1.1.3 gate would include 1.1.4, which lacks add_labels)
  • axis_labels docstring corrected (True adds labels)
  • crs_labels.png baseline regenerated at the post-TST: matplotlib 3.11 compatibility #313 (matplotlib 3.11) size; tests now also assert labels are present with axis_labels=True and absent by default

Tested locally: full suite passes with geopandas 1.2.0 / matplotlib 3.11.2; with geopandas 1.1.3 the label test is skipped and the rest pass.

jGaboardi and others added 2 commits October 13, 2026 20:25
- pass add_labels=axis_labels to GeoDataFrame.plot() when geopandas>=1.2.0
- gate label test on geopandas>=1.2.0 (1.1.4 lacks add_labels)
- fix axis_labels docstring
- regenerate crs_labels baseline at mpl 3.11 size; assert label presence/absence
@sjsrey
sjsrey requested a review from jGaboardi October 14, 2026 03:31
@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.2%. Comparing base (42f740a) to head (576901c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #323   +/-   ##
=====================================
  Coverage   90.1%   90.2%           
=====================================
  Files         11      11           
  Lines       1309    1314    +5     
=====================================
+ Hits        1180    1185    +5     
  Misses       129     129           
Files with missing lines Coverage Δ
mapclassify/value_by_alpha.py 91.3% <100.0%> (+0.4%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread mapclassify/value_by_alpha.py Outdated
Comment on lines +221 to +222
plot_kws = {"add_labels": axis_labels} if GPD_GE_120 else {}
gdf.plot(color=rgba, ax=ax, **plot_kws)

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.

Why don't we just pass kwargs in general? If we don't have a strong reason to remove the labels, we could even inherit geopandas behaviour and its controls here.

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.

@martinfleis Would you be able to provide an example of that? (how it differs from @sjsrey's code)

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.

 vba_choropleth(
    x,
    y,
    gdf,
    [...],
    **kwargs,
):
    [...]
    gdf.plot(color=rgba, ax=ax, **kwargs)
    [...]

just like this. This could be the whole diff of the PR. This automatically allows stuff like tiles=True, new automatic handling of labels in subplots and related change of the add_labels default to None etc. I don't think we need to do anything special here and I am not sure why we would want to deviate from geopandas and set add_labels to False by default.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

retain unlabeled axis behavior in vba_choropleth()

3 participants