Repository navigation
Conversation
- 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
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #323 +/- ##
=====================================
Coverage 90.1% 90.2%
=====================================
Files 11 11
Lines 1309 1314 +5
=====================================
+ Hits 1180 1185 +5
Misses 129 129
🚀 New features to boost your workflow:
|
| plot_kws = {"add_labels": axis_labels} if GPD_GE_120 else {} | ||
| gdf.plot(color=rgba, ax=ax, **plot_kws) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@martinfleis Would you be able to provide an example of that? (how it differs from @sjsrey's code)
There was a problem hiding this comment.
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 PR
vba_choropleth()#305main) and revises it to use theadd_labelskeyword from ENH: allow control of axis labels addition via add_labels in plot geopandas/geopandas#3767, released in geopandas 1.2.0, as discussed in VBA - retain unlabeled axis plotting behavior #306Changes on top of #306:
vba_choroplethpassesadd_labels=axis_labelstoGeoDataFrame.plot()whengeopandas>=1.2.0; older versions never add axis labels, so nothing is passed there. The manualset_xlabel("")/set_ylabel("")is dropped.importlib.metadata(no runtime dependency onpackaging)geopandas>=1.2.0(the previous>1.1.3gate would include 1.1.4, which lacksadd_labels)axis_labelsdocstring corrected (Trueadds labels)crs_labels.pngbaseline regenerated at the post-TST: matplotlib 3.11 compatibility #313 (matplotlib 3.11) size; tests now also assert labels are present withaxis_labels=Trueand absent by defaultTested 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.