PyPSA / pypsa-usa

PyPSA-USA: An Open-Source Energy System Optimization Model for the United States
https://pypsa-usa.readthedocs.io
MIT License
35 stars 14 forks source link

Address plotting warnings in `plot_statistics` #350

Open trevorb1 opened 1 month ago

trevorb1 commented 1 month ago

Feature Request

I think with the shift to mutl-index and planning horizons, plotting is giving us runtime warnings with the number of plots/subplots. Just warnings, so not a huge issue, but should still be addressed.

Suggested Solution

No response

Additional Info

Log output from plot_statistics.py

/home/trevor/repos/pypsa-usa/workflow/.snakemake/scripts/tmpl7xvv7r3.plot_statistics.py:750: RuntimeWarning:

More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`.

/home/trevor/repos/pypsa-usa/workflow/.snakemake/scripts/tmpl7xvv7r3.plot_statistics.py:797: RuntimeWarning:

More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`.

/home/trevor/repos/pypsa-usa/workflow/.snakemake/scripts/tmpl7xvv7r3.plot_statistics.py:929: FutureWarning:

A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.

WARNING:matplotlib.legend:No artists with labels found to put in legend.  Note that artists whose label start with an underscore are ignored when legend() is called with no argument.