在 x 轴上旋转底图子午线标签
Rotating Basemap Meridian labels on x-axis
是否可以旋转子午线标签使其不再重叠?有关示例,请参见下图。我不想减少子午线的数量。
我试过:
ax = plt.gca()
ax.set_xticklabels( meridians, rotation=45 )
虽然这在底图中没有任何作用。
子午线标签不是 x 轴标签。您仍然可以操作他们的文本对象:
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()
只需给出一个角度作为 mapproj.drawmeridians() 的 "rotation" 参数。
import mpl_toolkits.basemap as bm
mapproj = bm.Basemap(ax=ax1,projection='cyl',llcrnrlat=lat_mn, \
llcrnrlon= lon_mn,urcrnrlat= lat_mx, urcrnrlon=lon_mx)
mapproj.drawmeridians(lonlines, labels=[0,0,1,0],rotation=45)
就是这样!
干杯!
是否可以旋转子午线标签使其不再重叠?有关示例,请参见下图。我不想减少子午线的数量。
我试过:
ax = plt.gca()
ax.set_xticklabels( meridians, rotation=45 )
虽然这在底图中没有任何作用。
子午线标签不是 x 轴标签。您仍然可以操作他们的文本对象:
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()
只需给出一个角度作为 mapproj.drawmeridians() 的 "rotation" 参数。
import mpl_toolkits.basemap as bm
mapproj = bm.Basemap(ax=ax1,projection='cyl',llcrnrlat=lat_mn, \
llcrnrlon= lon_mn,urcrnrlat= lat_mx, urcrnrlon=lon_mx)
mapproj.drawmeridians(lonlines, labels=[0,0,1,0],rotation=45)
就是这样! 干杯!