add warnings for consistent legend sizes in combined geographical plots#1178
Merged
add warnings for consistent legend sizes in combined geographical plots#1178
Conversation
lkstrp
approved these changes
Mar 19, 2025
FabianHofmann
added a commit
that referenced
this pull request
Mar 24, 2025
* fix: `cartopy` warning * refactor: clean up and move to `plot.py` * refactor: start bigger `plot.py` refactoring * feat: use deprecation warning * feat: add deprecate kwargs decorator and deprecate cmap norms * refactor: modularise branch plotting * refactor: more clean up * refactor: add `NetworkPlotter` class * feat: close #302 * feat: return collections as dict * fix: don't filter deprecation warnings * refactor: deprecate `color_geomap` to `geomap_colors` * docs: add types and update docstring * follow up * plot: refactor * plot: refactor data series alignment for widhts, colors, alpha add legend for arrows * add balance plot function * plot: write static plots as functions on self * plot: fix axis and boundaries assignment * plot balance: add patch legend * plot: make new and old line scaling switchable * plot: ensure correct digit scaling in auto-unit * plot: fix flow aggregation & flow legend scaling * plot: track bus carrier units * follow up * fix: adress review comments * init restructure * follow up * add tests * add plotting consistency check to plotting * accessor: add carrier and component subplot handling * add more tests * test: Add comprehensive tests for plot accessors module * test: Add comprehensive test coverage for plot accessors module * fix: update test data to use valid carriers and avoid melt conflict * fix: ensure default gray colors are always included in carrier colors * fix: ensure default gray colors are always included in carrier colors * Simplify carrier color mapping logic in `_get_carrier_colors` * Fix `_create_base_plot` to handle missing carrier column * refactor: generalize plotting routines with dynamic column handling * Fix deprecation warnings and improve categorical data handling in plotting * refactoring * plot: fix negative and positive stacking * plot: follow up * plot_accessor: adjust tests * feat: add carrier attribute to statistics functions * feat: harmonise statistics maps plotter * sanitize ac_dc_meshed carriers and colors add statistics map plots * fix: capacity attribute in expressions, docstrings * feat: deprecated old pypsa.plot namespace * feat: complete type annotation in maps.py * fix: remove unneeded type ignores * fix: reinsert sanitize ac_dc_meshed, fix import from netcdf * rename utils.py to common.py to ease merge * fix: don't reuse self.ax per default in maps plots * feat: add carrier selection to statistics use explicit transformed points in the plotting routine * Plotting Library - Part 2 * review * fix tests * Update pypsa/plot/accessor.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: time aggregation in statistic plots * draft schema * create dedicated module for statistics maps * fix tests/ review * rename col/row to facet_col/facet_row * fix doc test * improve handling of stat_kwargs * fix: ingore ax type in statistic maps * more linter rules and docstrings * fix type checker * fix pre-commit * ifx tests * feat: use statistics handler as drop in method replacement * release note * fix type checker * improved release notes * move `n.plot.energy_balance` to `n.statistics.energy_balance` * deprecate old namespace * fix tests * fix types * add `.plot` accessor * feat: use seaborn facet grid instead of seaborn objects * rename test_plot_charts * save test plots option * improved schema and add `kind` argument for `.plot()` * fix base plot test * add plot hashs in tests * fix: nice names for both charts and maps fix: area and bar plots for facet grid feat: add arguments for sharey and sharex * fix: imports in test_plot_stats * fix: refine case distinction for custom chart plot routine * fix doc tests * fix: types and docstrings in plotter.py * refac: facilitate charts.py * feat: improve defaults * doctests * improved plot hash tests * hash tests * refac: define arguments in chart functions fix: weid pandas ylim behavior * fix: default arguments for static area plots * feat: backwardscompatible flow argument, pull in #1179 * update plot hashes * support missing colors in statistic map plot * install cartopy in ci * fix: ignore types for _shared_axes * update plot hashes * use `pytest-mpl` * take over #1178 * refac remove unneeded cartopy tests * fix tests * use fix fig size * add seed * fix: linopy deprecation in examples * use fixed dpi * also use fixed figsize * fix: try to reorder multiplication in doc example * another dpi * use global rc setting * fix: multiplication for numpy version >= 2.0 * change figsize again * reset to rc defaults * disable mpl test on maps * fix: deprecation case for flow argument --------- Co-authored-by: Fabian <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this Pull Request
There are some interactions with combined PyPSA and Geopandas plots on a single geographical axis. Depending on the order of execution, the legend circle sizes are correct or incorrext (
add_legend_circles()andadd_legend_semicircles()).The problem is the changing extent of the plot, which is changed here:
https://github.com/PyPSA/pypsa/blob/fneum/legend-circle-sizes/pypsa/plot.py#L242-L243
and accessed here to calculate in
projected_area_factor().https://github.com/PyPSA/pypsa/blob/df3beba8b8aec071fcbe61800d6358552d76eba6/pypsa/plot.py#L534
I have no idea how to properly it (apart from running
n.plot()first), but a first measure would be to warn about what the right order of execution would be.MWE
Output of a)
Output of b)
Checklist
doc.doc/release_notes.rstof the upcoming release is included.