下面是一个Basemap示例:
fig = plt.figure(figsize=(10,6))
ax = fig.add_subplot(121)
ax.set_title('Default')
# miller projection
map = Basemap(projection='mill',lon_0=180)
# plot coastlines, draw label meridians and parallels.
map.drawcoastlines()
map.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0])
map.drawmeridians(np.arange(map.lonmin,map.lonmax+30,60),labels=[0,0,0,1])
ax = fig.add_subplot(122)
ax.set_title('Add offset')
# miller projection
map = Basemap(projection='mill',lon_0=180)
# plot coastlines, draw label meridians and parallels.
map.drawcoastlines()
map.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0],xoffset=100,yoffset=100)
map.drawmeridians(np.arange(map.lonmin,map.lonmax+30,60),labels=[0,0,0,1],xoffset=100,yoffset=100)
我想在xlabel/ylabel和axis之间添加更多空间。
但是,添加xoffset
和yoffset
时,空间更小。在
basemap
不再积极开发,但维护仍将持续一段时间。这意味着,由于其他包中的更改而中断的内容仍将被修复,但不会添加新功能。不管怎么说,修复部分可能需要一些时间,我猜平行线和子午线的xoffset
特性正是受此影响。但是,查看basemap
文档,xoffset
和{通过操作
drawparallels()
和drawmeridians()
生成的Text
对象很容易进行仿真。这些函数的结果存储在一个dict
中,其中包含每个绘制的平行/子午线的一个元组列表,其中第二个包含文本标签。一个Text
对象有一个get_position()
和一个set_position()
方法,结合轴限制和上述定义,可用于计算偏移量:结果图如下:
相关问题 更多 >
编程相关推荐