You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PS_CONVERT has no effect when using Figure.show/Figure.savefig/Figure.psconvert #4256
Comma-separated list of optional module arguments that we should supply when psconvert is called implicitly under modern mode [A]. Ignored when psconvert is called on the command line explicitly. The option arguments must be listed without their leading option hyphen.
In PyGMT, Figure.show/Figure.savefig calls psconvert internally, so this option has no effect, which is expected according to the GMT documentation. As a workaround, we can explicitely add these options when calling Figure.show/Figure.savefig, but it's a little tedious.
Possible solutions are:
Document that PS_CONVERT is ignored in PyGMT.
In Figure.psconvert, parse the values of PS_CONVERT and append them to the argument list when calling psconvert.
Thinking about if there is a more Pythonic and elegant way to implement the same feature.
Solution 2 is not that hard to implement, but need time to think about solution 3.
After comparing Solutions 1 and 2, I prefer Solution 1.
The argument of PS_CONVERT (e.g., pygmt.config(PS_CONVERT="C-I/home/xxx/.gmt,E300") is not readable and not Pythonic. Users have to read through the GMT documentation to understand its meaning. It also changes the global configuration, which may have side-effect.
Instead of setting PS_CONVERT, user can set parameters when calling Figure.savefig/Figure.show, which is more readable and Pythonic:
Using gs_option (i.e. -C in psconvert) sounds reasonable. Maybe we can also remove or comment out PS_CONVERT from the autocomplete at so that people don't use it accidentally?
Raise a warning if pygmt.config(PS_CONVERT=...) is used.
Remove PS_CONVERT from autocomplete
Or is there a way still to make the PS_CONVERT config work if used globally?
In GMT CLI, PS_CONVERT is only used when calling gmt end. To make it work in PyGMT, we have to parse the value of PS_CONVERT and pass the CLI options psconvert when calling Figure.savefig/Figure.show. See the initial version in PR #4342
In GMT CLI, PS_CONVERT is only used when calling gmt end. To make it work in PyGMT, we have to parse the value of PS_CONVERT and pass the CLI options psconvert when calling Figure.savefig/Figure.show. See the initial version in PR #4342
This chunk of code is a little trickier to understand/maintain. So would lean towards just raising a warning when PS_CONVERT is used as you suggested ^.
Activity
seisman commentedon Jan 12, 2026
Thanks @Chuan1937 for tackling this in PR #4342.
After comparing Solutions 1 and 2, I prefer Solution 1.
The argument of
PS_CONVERT(e.g.,pygmt.config(PS_CONVERT="C-I/home/xxx/.gmt,E300")is not readable and not Pythonic. Users have to read through the GMT documentation to understand its meaning. It also changes the global configuration, which may have side-effect.Instead of setting
PS_CONVERT, user can set parameters when callingFigure.savefig/Figure.show, which is more readable and Pythonic:If the same parameters need to be reused, it's easy to define a dict and pass it to
Figure.savefig/Figure.showwhen needed. E.g.,seisman commentedon Jan 13, 2026
@GenericMappingTools/pygmt-maintainers Any comments?
weiji14 commentedon Jan 13, 2026
Using
gs_option(i.e.-Cin psconvert) sounds reasonable. Maybe we can also remove or comment outPS_CONVERTfrom the autocomplete atpygmt/pygmt/src/config.py
Line 138 in b1d4bd7
so that people don't use it accidentally? Or is there a way still to make the
PS_CONVERTconfig work if used globally?seisman commentedon Jan 13, 2026
With Solution 1, I think we should do:
PS_CONVERTis not supported in thepygmt.configdocumentation [Already done in Add a note/warning that PS_CONVERT is not supported #4342]pygmt.config(PS_CONVERT=...)is used.PS_CONVERTfrom autocompleteIn GMT CLI,
PS_CONVERTis only used when callinggmt end. To make it work in PyGMT, we have to parse the value ofPS_CONVERTand pass the CLI optionspsconvertwhen callingFigure.savefig/Figure.show. See the initial version in PR #4342pygmt/pygmt/src/psconvert.py
Lines 146 to 166 in 26c0c6d
weiji14 commentedon Jan 13, 2026
This chunk of code is a little trickier to understand/maintain. So would lean towards just raising a warning when
PS_CONVERTis used as you suggested ^.