How to put a map scale bar and add transparency to a map grid in Pygmt?

Hello all, I am new in Pygmt and I liked the way that it works! But I have some questions, I am trying to put a map scale bar in my pygmt code, I have already read the web tutorial but I cannot get a correct result.So there are some fantastic examples (that is appreciated) but not about specific things. Also I need to add transparency to my map grid because is black color.And someone does know how to minimize the letter N in the rose(I copied from a web code)?. I tried to use the predefined codes for GMT, but it fails. The example code is the next:

import pygmt

fig = pygmt.Figure()

# generate a basemap near Washington state showing coastlines, land, and water
fig.coast(
    region=[-125, -122, 47, 49],
    projection="M6c",
    land="grey",
    water="lightblue",
    shorelines=True,
    frame="ag",
)

fig.basemap(rose="jTL+w1.3c+lO,E,S,N+o-0.1c/3c") #map directional rose at the top left corner 
fig.savefig("japan.png")
fig.show()

Map scale bar can be added by specifying the map_scale parameter in basemap or coast. The text size of ā€œNā€ is controlled by the GMT setting FONT_TITLE:

import pygmt

fig = pygmt.Figure()

# generate a basemap near Washington state showing coastlines, land, and water
fig.coast(
    region=[-125, -122, 47, 49],
    projection="M6c",
    land="grey",
    water="lightblue",
    shorelines=True,
    frame="ag",
    
)
with pygmt.config(FONT_TITLE=8):
    fig.basemap(rose="jTL+w1.3c+lO,E,S,N+o-0.1c/3c", map_scale="jBL+w50k+o0.5c/0.5c+f") 
fig.savefig("japan.png")
fig.show()
2 Likes

Thanks very much!!! My map looks nice!!. Only I am trying how to change the color of the map grid and low the intensity.