pygmt: Colorbar annotation size does not change

Description of the problem

I set the FONT_ANNOT_PRIMARY and FONT_LABEL to 20 but the annotation on the colorbar does not change

Minimal Complete Verifiable Example

import pygmt

pygmt.config(FONT_LABEL = 20)
pygmt.config(FONT_ANNOT_PRIMARY = 20)

fig = pygmt.Figure()
fig.colorbar(position="x+3.68i/0.38i+w1.9i/0.090i+ef+mul+h", frame="a100f50", cmap=cptFileSlip)
fig.show()

Full error message

No response

System information

PyGMT information:
  version: v0.10.0
System information:
  python: 3.11.7 (main, Dec 10 2023, 14:13:07) [Clang 15.0.0 (clang-1500.0.40.1)]
  executable: /opt/local/bin/python
  machine: macOS-14.3-arm64-arm-64bit
Dependency information:
  numpy: 1.26.2
  pandas: 2.1.1
  xarray: 2022.12.0
  netCDF4: 1.6.5
  packaging: 23.2
  contextily: None
  geopandas: None
  IPython: 8.14.0
  rioxarray: None
  ghostscript: 10.02.1
GMT library information:
  binary version: 6.5.0
  cores: 10
  grid layout: rows
  image layout: 
  library path: /opt/local/lib/gmt6/lib/libgmt.dylib
  padding: 2
  plugin dir: /opt/local/lib/gmt6/lib/gmt/plugins
  share dir: /opt/local/lib/gmt6/share/gmt
  version: 6.5.0

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

Oh yeah, I just remembered #733, the pygmt.config call needs to be placed below fig = pygmt.Figure(). E.g.:

fig = pygmt.Figure()
with pygmt.config(
    FONT_LABEL="30p,Helvetica,red", FONT_ANNOT_PRIMARY="30p,Helvetica,red"
):
    fig.colorbar(
        position="x+3.68i/0.38i+w1.9i/0.090i+ef+mul+h",
        frame="a0.2f50",
        cmap="batlow",
    )
    fig.savefig("temp30.png")
    fig.show()

produces:

temp30

Can you please try to see if it works when config is called after initializing the Figure instance:

import pygmt

size = 5

# pygmt.config(FONT_LABEL = 20)
# pygmt.config(FONT_ANNOT_PRIMARY = 20)

fig = pygmt.Figure()

pygmt.config(FONT_LABEL=20)
pygmt.config(FONT_ANNOT_PRIMARY=20)

fig.basemap(region=[-size, size, -size, size], projection=f"X{size}c", frame=True)
fig.colorbar(cmap="jet", position="jMC", frame=True)

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

Output figure: config_font