Marek
Marek

Reputation: 170

Getting xtick and ytick on a polar stereographic plot with matplotlib / python

I kind of know that my problem is probably super simple, but I can not solve it.

I use Basemap to plot a polarstereographic map of the arctic, but I am not able to plot the longitude values on the axis. I want to have the values of the coordinates plotted on the axis.

My code looks the following at the moment:

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np

plt.figure()
m = Basemap(projection='npstere',boundinglat=70,lon_0=270,resolution='l')
m.drawcoastlines()
m.drawparallels(np.arange(-80.,81,10.))
m.drawmeridians(np.arange(-180.,181.,20.))
plt.show()

I'm thankful for any advice.

Upvotes: 1

Views: 303

Answers (1)

Thomas Kühn
Thomas Kühn

Reputation: 9820

You need to tell Basemap explicitly that you want labels. You cannot do this with the usual set_xticklabels() command, because basemap does not use this functionality, but instead draws its labels differently. Instead, use the keyword labels in the drawmeridians() function. In particular, the following command

m.drawmeridians(np.arange(-180.,181.,20.), labels=[True, True, True, True])

will draw labels on all four sides of the map. See the documentation for more details.

Upvotes: 1

Related Questions