I'm using cartopy
to draw a geomap. This is how I set up graticule
rendering:
if graticule:
gl = ax.gridlines(
draw_labels=True,
linewidth=0.8,
color='gray',
alpha=0.5,
linestyle='--',
x_inline=False,
y_inline=True
)
gl.xlocator = mticker.FixedLocator(np.arange(-180, 181, 10))
gl.ylocator = mticker.FixedLocator(np.arange(0, 91, 10))
gl.top_labels = False
gl.bottom_labels = True
gl.left_labels = True
gl.right_labels = True
gl.xlabel_style = {'size': 10, 'color': 'gray'}
gl.ylabel_style = {'size': 10, 'color': 'gray'}
cartopy
doesn't draw longitude labels to the left and to the right of the map. Only bottom and top (if on) labels are drawn:
With ax.set_extent([0, 40, 75, 85], crs=ccrs.PlateCarree())
added:
Latitude labels are okay being inline.
In draw_labels parameter, instead of setting it to True you can pass a dictionary with each 4 side and which coordinates you wish to see:
gl = ax.gridlines(
draw_labels={"bottom": "x", "left": "x", "right":"x"},
linewidth=0.8,
color='gray',
alpha=0.5,
linestyle='--',
x_inline=False,
y_inline=True
)
You will also need to remove these 4 lines:
# gl.top_labels = False
# gl.bottom_labels = True
# gl.left_labels = True
# gl.right_labels = True