是否可以旋转子午线标签以使它们不再重叠?有关下面的示例,请参见图像。我不想减少子午线的数量。
我试过了:
ax = plt.gca()
ax.set_xticklabels( meridians, rotation=45 )
虽然这在底图中没有做任何事情。
答案 0 :(得分:5)
子午线标签不是xaxis标签。您仍然可以操纵他们的文本对象:
from mpl_toolkits.basemap import Basemap, cm
import numpy as np
import matplotlib.pyplot as plt
# create figure and axes instances
fig = plt.figure(figsize=(8,8))
ax = fig.add_axes([0.1,0.1,0.8,0.8])
# create polar stereographic Basemap instance.
m = Basemap(projection='stere',lon_0=0,lat_0=30.,lat_ts=45.,\
width=10000000, height=4000000,
rsphere=6371200.,resolution='l',area_thresh=10000)
m.drawcoastlines()
m.drawstates()
m.drawcountries()
# draw parallels.
parallels = np.arange(0.,90,5.)
m.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
# draw meridians
merid_values = np.arange(0.,360.,10.)
meridians = m.drawmeridians(merid_values,labels=[0,0,0,1],fontsize=10)
for m in meridians:
try:
meridians[m][1][0].set_rotation(45)
except:
pass
plt.show()
答案 1 :(得分:1)