pythonlabelfont-sizegmtpygmt

Labelling the latitude and longitude on both axis. and increasing their fontsize


I have a simple code to create a pygmt map. However, I am not able to change the fontsize of the Latitude/longitude labels .

The sample code is here.

import pygmt
fig = pygmt.Figure()

grid = pygmt.datasets.load_earth_relief(resolution="20m", region=[50,65,10,25])
pygmt.makecpt(series=[-8000,4000])

fig.grdimage(grid=grid, projection="M15c", frame="a", cmap="geo",dpi=300)
fig.grdcontour(grid=grid,projection="M15c", levels=1000,frame="a")
fig.colorbar(frame=["a1000f100", "x+lDepth/Elevation (m)", "y+lm"], position="g51/6+w13c/0.5c+h")
fig.show()

In my understanding, I did mess around but couldn't find any solution.


Solution

  • To change the GMT default parameters locally, pygmt.config can be used together with a context manager. You can use Figure.basemap to set up a basic map.

    import pygmt
    
    projection = "M15c"
    region = [50, 65, 10, 25]
    grid = pygmt.datasets.load_earth_relief(resolution="20m", region=region)
    
    
    fig = pygmt.Figure()
    
    with pygmt.config(FONT="20p"):
        fig.basemap(region=region, projection=projection, frame="a")
    
    fig.grdimage(grid=grid, cmap="geo", dpi=300)
    fig.grdcontour(grid=grid, levels=1000)
    fig.colorbar(
        frame=["a1000f100", "x+lDepth/Elevation (m)", "y+lm"],
        position="g51/6+w13c/0.5c+h",
    )
    
    fig.show()
    
    

    enter image description here