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
Allow for overriding default gmt values (--PAR=value) in pygmt routines #455
gmt routines allows to temporarily override a default value by adding the string --PAR=value to a gmt function call. For example, this is useful for quickly changing font sizes of labels and annotations.
Though pygmt routines pass kwargs that are reformatted by the functionbuild_arg_string, this does not correctly deal with overriding default parameters. In particular, build_arg_string only adds a single dash, and not two, to the output.
Instead of the --PAR=value, we already implement the similar feature in #293.
pygmt.config(PARAMETER=value) # Set global settings
# Locally set a value that will revert back to the default
with pygmt.config(PROJ_ELLIPSOID=value): # set local settings
...
pygmt.whatever(...)
This will work. But it would help streamline things if you were allowed to temporarily override a parameter in a pygmt function. Otherwise, you need to set the variables before the call, and then unset them afterwards. If you don't plan on implementing this, just feel free to close this issue.
Otherwise, you need to set the variables before the call, and then unset them afterwards.
No. I have to confess that the pygmt.config() "function" is not well documented. Here is an example showing how pygmt.config() works. The settings in the with block are temporary and are automatically "unset" afterward.
I didn't realize that you could use config as a context manager. If we could highlight this in a tutorial and/or documentation, then there's no reason to do what I originally asked.
Activity
seisman commentedon May 24, 2020
Instead of the
--PAR=value, we already implement the similar feature in #293.MarkWieczorek commentedon May 25, 2020
This will work. But it would help streamline things if you were allowed to temporarily override a parameter in a pygmt function. Otherwise, you need to set the variables before the call, and then unset them afterwards. If you don't plan on implementing this, just feel free to close this issue.
seisman commentedon May 25, 2020
No. I have to confess that the
pygmt.config()"function" is not well documented. Here is an example showing howpygmt.config()works. The settings in thewithblock are temporary and are automatically "unset" afterward.This is what the figure looks like:

MarkWieczorek commentedon May 26, 2020
I didn't realize that you could use
configas a context manager. If we could highlight this in a tutorial and/or documentation, then there's no reason to do what I originally asked.