2016-03-18 37 views
0

我想根据默认设置生成“放大”的南极洲的正交(极坐标)图。默认情况下,我得到这个:正射投影的限制范围(缩放)

Antarctica polar

下面的脚本生成此。

import cartopy.crs as ccrs 
import matplotlib.pyplot as plt 

ax = plt.axes(projection=ccrs.Orthographic(central_longitude=0.0, central_latitude=-90.)) 
ax.stock_img() 
plt.show() 

我最好告诉Cartopy“限制纬60S至90年代的企图是:

ax.set_extent([-180,180,-60,-90], ccrs.PlateCarree()) 

遗憾的是它不给desired result。有任何想法吗?提前致谢。

回答

0

我不确定我完全明白你想要做什么。你的例子看起来像是一个已定义的边界框,但是你希望它像第一个例子那样圆形?

cartopy文档有http://scitools.org.uk/cartopy/docs/latest/examples/always_circular_stereo.html的例子:

import matplotlib.path as mpath 
import matplotlib.pyplot as plt 
import numpy as np 

import cartopy.crs as ccrs 
import cartopy.feature 


def main(): 
    fig = plt.figure(figsize=[10, 5]) 
    ax1 = plt.subplot(1, 2, 1, projection=ccrs.SouthPolarStereo()) 
    ax2 = plt.subplot(1, 2, 2, projection=ccrs.SouthPolarStereo(), 
         sharex=ax1, sharey=ax1) 
    fig.subplots_adjust(bottom=0.05, top=0.95, 
         left=0.04, right=0.95, wspace=0.02) 

    # Limit the map to -60 degrees latitude and below. 
    ax1.set_extent([-180, 180, -90, -60], ccrs.PlateCarree()) 

    ax1.add_feature(cartopy.feature.LAND) 
    ax1.add_feature(cartopy.feature.OCEAN) 

    ax1.gridlines() 
    ax2.gridlines() 

    ax2.add_feature(cartopy.feature.LAND) 
    ax2.add_feature(cartopy.feature.OCEAN) 

    # Compute a circle in axes coordinates, which we can use as a boundary 
    # for the map. We can pan/zoom as much as we like - the boundary will be 
    # permanently circular. 
    theta = np.linspace(0, 2*np.pi, 100) 
    center, radius = [0.5, 0.5], 0.5 
    verts = np.vstack([np.sin(theta), np.cos(theta)]).T 
    circle = mpath.Path(verts * radius + center) 

    ax2.set_boundary(circle, transform=ax2.transAxes) 

    plt.show() 

if __name__ == '__main__': 
    main() 
+0

感谢马特,事实上,我一直在寻找一种方式来产生圆润的曲线,但约束边界坐标(在这种情况下,纬度)。你提供的例子正在解决这个问题。尽管如此,这并不适用于插入'ax2.stock_img()',但这没有什么大不了的。 –