How to set default parameters in PyGMT?

Is there a standard way how to set the default parameters like FONT_ANNOT_PRIMARY etc. using PyGMT? I read about some suggestions regarding that topic on GitHub but currently I’m not sure how to set the different parameters.

Not at the moment. There has been some work in progress code at but it has not been merged into master yet. Are you trying to just change the font sizes/colours?

Good to know :wink: Yes my main problem was to change the fontsize of the colorbar and the map frame annotations. Does any workaround exist for this issue at the moment?

Not exactly the best way, but I usually just change the scale of the map projection (e.g. from projection="x1:30000" to projection="x1:60000").

I use this workaround to call gmtset directly.

import pygmt
with pygmt.clib.Session() as session:
    session.call_module('gmtset', 'FONT 11p')
    session.call_module('gmtset', 'MAP_FRAME_TYPE fancy')

Thanks for your answers, the latter one works fine for me until the “offical” way how to do it will be implemented :wink:

FYI, has been merged into master, so you can now do the following after running pip install

pygmt.config(PARAMETER=value)  # Global

# Locally set a value that will revert back to the default
with pygmt.config(PROJ_ELLIPSOID=value):

Awesome. I’m not seeing it documented on yet — docs build issue?

Also, if you have an existing install of PyGMT and you’re like me and are confused why

pip install

doesn’t actually grab the newest code, try running

pip uninstall pygmt

first. :slight_smile:

Something’s been acting up with our Travis CI, I’ll take a look! ~~In the meantime, you can try the temporary link at Edit: Documentation on now refreshed with Fix Github Pages deployment from Travis by weiji14 · Pull Request #410 · GenericMappingTools/pygmt · GitHub.

1 Like

Great to see it’s finally implemented. Thanks!