Figure.show: Allow keyword arguments passed to Figure.psconvert#2078
Figure.show: Allow keyword arguments passed to Figure.psconvert#2078
Conversation
pygmt/figure.py
Outdated
| **kwargs : dict | ||
| Additional keyword arguments passed to | ||
| :meth:`pygmt.Figure.psconvert`. |
There was a problem hiding this comment.
Unsure if we should use kwargs or **kwargs here.
There was a problem hiding this comment.
I had a look at some projects and there seems to be a mix 😅. Let's go with **kwargs following https://docs.xarray.dev/en/v2022.06.0/generated/xarray.open_dataset.html, unless anyone else has a good reason on why not.
pygmt/figure.py
Outdated
| dpi : int | ||
| Set raster resolution in dpi. Default is 720 for PDF, 300 for | ||
| others. | ||
| **kwargs : dict | ||
| Additional keyword arguments passed to | ||
| :meth:`pygmt.Figure.psconvert`. |
There was a problem hiding this comment.
I find it a bit confusing that dpi (an option in psconvert) was previously an extra option or kwarg, but now there's both dpi and **kwargs in the Figure.savefig(...) method shown in the documentation:
.
Not sure what's the best solution here. Removing the dpi parameter documentation doesn't seem ideal, nor does including all of psconvert's parameters in savefig. Would it make sense then to put the dpi documentation under **kwargs? Or is there a cleaner solution?
There was a problem hiding this comment.
I agree. Actually some of psconvert's parameters (e.g., prefix, fmt) can NOT be used in Figure.show or Figure.savefig.
Perhaps we should say:
**kwargs: dict
Additional keyword arguments passed to `pygmt.Figure.pscovert`.
Valid parameters are `gs_path`, `gs_option`, `resize`, `bb_style`, and `verbose`.
There was a problem hiding this comment.
Yes! Also need to do a similar thing for the fig.show docstring.
Description of proposed changes
Add
**kwargstoFigure.showso that it can pass any keyword arguments toFigure.psconvert.Figure.savefig()already have**kwargs.Fixes #2038
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.Slash Commands
You can write slash commands (
/command) in the first line of a comment to performspecific operations. Supported slash commands are:
/format: automatically format and lint the code/test-gmt-dev: run full tests on the latest GMT development version