FONT SIZE doesn't change (regardless of what I do)

Hello fellow Pygmtnians,
As much as I try to change the font size with pygmt.config, it simply “ignores” what I’m asking. Any idea what could be wrong?
I’ve tried FONT_LABEL, FONT_ANNOT_PRIMARY, and obviously I played 100p to see if there’s any change. Obviously I’m going to choose a lower value, but…
Any idea is welcome.

Hello @andrebelem,

you have to set up the Figure object before you can change the GMT defaults:

Code example:

import pygmt

size = 5

fig = pygmt.Figure()

# The change of the font size applies only to the stuff happening
# within the with block
with pygmt.config(FONT="50p"):
    
    fig.basemap(
        region=[-size, size, -size, size],
        projection="X" + str(size*2) + "c",
        frame=["WSne", "afg"],
    )

fig.basemap(
    frame="+tretains default font size",
)

fig.show()
# fig.savefig(fname="change_font_size_locally.png")

Output figure:

humm ! Understood (partialy).
I actually need to set the projection size (in cm for example) for the font size to take effect. It’s a combined process. I did some tests here and it solved it, but in a slightly different way than what you showed.
Thanks again.

No, it’s not necessary.

The following code works well for me:

import pygmt
with pygmt.config(FONT_LABEL="100p"):
    fig = pygmt.Figure()
    fig.basemap(region=[0, 10, 0, 10], projection="X10c", frame=["WSen", "x+lXlabel", "y+lYlabel"])
    fig.show()
1 Like

While this does work for the label font, I had no luck with it for the title, and had to resort to @yvonnefroehlich 's solution.

Thank you to both!