2013-01-05 57 views
3

我想在剧情的底部绘制一幅北半球的极地立体图,其中有180个,所以我可以强调太平洋地区。我使用git最新的cartopy,并且可以制作极地立体图,但我无法弄清楚如何更改哪个经度位于图的底部。我尝试将经度范围设置为[-180,180],但这没有帮助,并且NorthPolarStereo()不接受像central_longitude这样的任何关键字参数。目前这可能吗?NorthPolarStereo的中心经度

+0

短回答:不,但我看到你已经添加了一个拉请求https://github.com/SciTools/cartopy/pull/188,它增加了这个功能。为了让将来其他人都知道如何去做,你会介意添加一个使用你的新代码的例子。干杯! – pelson

回答

3

此功能现已在Cartopy(v0.6.x)中实现。以下示例会产生在北半球极性立体投影2副区,一个与所述默认设置和一个与中心经度变化:

"""Stereographic plot with adjusted central longitude.""" 
import matplotlib.pyplot as plt 
import cartopy.crs as ccrs 
from cartopy.examples.waves import sample_data 


# read sample data 
x, y, z = sample_data(shape=(73, 145)) 

fig = plt.figure(figsize=(8, 4)) 

# first plot with default settings 
ax1 = fig.add_subplot(121, projection=ccrs.NorthPolarStereo()) 
cs1 = ax1.contourf(x, y, z, 50, transform=ccrs.PlateCarree(), 
        cmap='gist_ncar') 
ax1.set_extent([0, 360, 0, 90], crs=ccrs.PlateCarree()) 
ax1.coastlines() 
ax1.set_title('Centred on 0$^\circ$ (default)') 

# second plot with 90W at the bottom of the plot 
ax2 = fig.add_subplot(
    122, projection=ccrs.NorthPolarStereo(central_longitude=-90)) 
cs2 = ax2.contourf(x, y, z, 50, transform=ccrs.PlateCarree(), 
        cmap='gist_ncar') 
ax2.set_extent([0, 360, 0, 90], crs=ccrs.PlateCarree()) 
ax2.coastlines() 
ax2.set_title('Centred on 90$^\circ$W') 

plt.show() 

这个脚本的输出是:

NH polar stereographic

+0

谢谢@ajdawson - 不错的答案:-) – pelson