Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add file output to cli plotting #35

Merged
merged 2 commits into from
Feb 4, 2025
Merged

Conversation

thomaszwagerman
Copy link
Collaborator

@thomaszwagerman thomaszwagerman commented Dec 6, 2024

Addresses #22

Adding the ability to write files using the asli_plot cli command. Adding the -y --year parameter to trigger either a.plot_region_all() or a.plot_region_year().

Generalising the common -o --output parameter description.

@thomaszwagerman thomaszwagerman self-assigned this Dec 6, 2024
@thomaszwagerman
Copy link
Collaborator Author

There's a couple of design decisions to discuss:

  1. Importing plt in asli.py just to call plt.savefig() (to quickly make this work). Would it be better to define a separate function in plot.py and from .plot import ...
  2. Passing additional arguments plt.savefig() can take (e.g. dpi, bbox_inches, see matplotlib docs). Is there an elegant way to do this or would it be a case of writing out additional _get_cli_plot_args() arguments?

@davidwilby
Copy link
Owner

Again sorry for the delay!! 😭

1. Importing plt in asli.py just to call `plt.savefig()` (to quickly make this work). Would it be better to define a separate function in plot.py and from .plot import ...

I don't actually mind either way, ultimately plt/matplotlib gets imported so it doesn't do anything for us in terms of speed/resources, but it may be tidier to keep all lower-level plotting in the plot module. Not a big deal either way for this package I think but it's always good to consider these choices.

2. Passing additional arguments `plt.savefig()` can take (e.g. `dpi`, `bbox_inches`, see [matplotlib docs](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html)). Is there an elegant way to do this or would it be a case of writing out additional `_get_cli_plot_args()` arguments?

This I'm not entirely sure about, but it would be nice to give the user control of all of those params from the CLI I guess? Here follows a stream of consciousness in lieu of any actual coherent thoughts:

I kind of think that we should allow some common options (i.e. anything we need) but only give the user fine control over the plotting object by just returning it for their use.

So at the moment the plot module is just a small collection of convenience functions but maybe we should have a class or maybe as in asli.plot.plot_lows returning the axis object is sufficient? I'm not particularly au fait with matplotlib so unsure whether this would be ordinary practice.

@thomaszwagerman thomaszwagerman marked this pull request as ready for review January 29, 2025 15:42
@thomaszwagerman thomaszwagerman merged commit a9ee34a into packaging Feb 4, 2025
4 checks passed
@thomaszwagerman thomaszwagerman deleted the plotting_engine branch February 4, 2025 08:59
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.

2 participants