1

I'm making a map using matplotlib.pyplot and I used the gridlines feature to create "labels" on the x and y axis of degrees latitude and longitude. I set the gridlines color to "none" to avoid having the gridlines there. However, these labels appear on each side of the plot and, at one point, coincide with my colorbar. Is there a way I could make these gridline labels only appear on the bottom and left of the plot? I can't find a list of the available kwargs anywhere. This is the code I used:

ax.gridlines(draw_labels=True, color="none")

And here is an image of the map. I would ideally like to remove the degree labels on the right and top axes.

enter image description here

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
  • Maybe [How to remove or hide x-axis labels from a seaborn / matplotlib plot](https://stackoverflow.com/q/58476654/7758804) – Trenton McKinney Aug 10 '21 at 00:16
  • 1
    Please see [How to ask a good question](https://stackoverflow.com/help/how-to-ask). Always provide a complete [mre] with **code, data, errors, current output, and expected output**, as **[formatted text](https://stackoverflow.com/help/formatting)**. If relevant, only plot images are okay. – Trenton McKinney Aug 10 '21 at 00:26

1 Answers1

2

You can achieve what you need with these relevant code:-

# minor change to the existing line of code
gls = ax.gridlines(draw_labels=True, color="none")

# other lines of code

# add these before plotting
gls.top_labels=False   # suppress top labels
gls.right_labels=False # suppress right labels
swatchai
  • 17,400
  • 3
  • 39
  • 58