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
import pygmt creates a new session, and pygmt.config() changes GMT's global settings. The script can produce a plot with a large annotation font size, as expected.
Then, in the same jupyter notebook, we can change the annotation font size 20p to 6p, and run the script again. It still produces a plot with a large annotation font size.
We can rewrite the above processes into a single script, like below:
# "import pygmt" start a new sessionimportpygmt# it changes GMT's global settingspygmt.config(FONT_ANNOT="20p")
projection="A-95/42/4i"region="-119/22/-50/50r"fig=pygmt.Figure()
# the basemap has an annotation font size of 20p, as determined by the global FONT_ANNOT settingfig.basemap(
region=region,
projection=projection,
frame=True,
)
fig.show()
# here, "import pygmt" doesn't start a new sessionimportpygmt# here, "pygmt.config()" changes the **local** settings of the **previous** figure, so it doesn't affect the next figurepygmt.config(FONT_ANNOT="6p")
projection="A-95/42/4i"region="-119/22/-50/50r"fig=pygmt.Figure()
# the basemap still has an annotation font size of 20p, as determined by the global FONT_ANNOT settingfig.basemap(
region=region,
projection=projection,
frame=True,
)
fig.show()
Activity
seisman commentedon Dec 14, 2020
Setting
pygmt.config(FONT_ANNOT="6p")should work. Could you please provide your full codes?uliw commentedon Dec 14, 2020
Here is an example. Changing the value from 6 to e.g., does not affect the font size
seisman commentedon Dec 14, 2020
OK. I can reproduce your issue. Will see why it doesn't work as expected.
Here is a workaround:
uliw commentedon Dec 14, 2020
seisman commentedon Dec 14, 2020
Here is the step to reproduce the issue and understand why it doesn't work as expected.
We first need to start a jupyter notebook, and run the following script.
import pygmtcreates a new session, andpygmt.config()changes GMT's global settings. The script can produce a plot with a large annotation font size, as expected.Then, in the same jupyter notebook, we can change the annotation font size
20pto6p, and run the script again. It still produces a plot with a large annotation font size.We can rewrite the above processes into a single script, like below:
weiji14 commentedon Feb 17, 2021
My reading of this issue is that it is a problem related to having one GMT session open all the time in PyGMT (c.f. #867). Either we:
fig.destroy()/fig.clear()(or similar) methodwith pygmt.Figure() as fig: fig.* ...to keep the scope of things local.pygmt.configin awithstatement so that things are kept to a local scope only.This is needed to ensure that one figure session doesn't pollute the configurations of subsequent figures.
seisman commentedon Feb 18, 2021
Or we could document the behavior of
pygmt.config()better.