i'm trying create contour plot on north polar stereographic map projection using cartopy. used add_cyclic_point()
try , around problem of having gap between longitude 0 , longitude 35x , followed example documentation (always_circular_stereographic
) set map axes.
when call plt.contour
, following plot. looks contour plotter getting confused @ transition 355 0 longitude, , sends contour lines around globe.
here code:
import numpy np import cartopy.crs ccrs cartopy.util import add_cyclic_point import matplotlib.pyplot plt def define_map(): matplotlib.path import path fig = plt.figure(figsize=(10,10)) ax = plt.axes(projection=ccrs.northpolarstereo()) ax.coastlines() # example: http://scitools.org.uk/cartopy/docs/latest/examples/always_circular_stereo.html 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 = path(verts * radius + center) ax.set_boundary(circle, transform=ax.transaxes) return(fig, ax) lats = np.arange(65,91,5) lons = add_cyclic_point(np.arange(0,359,5)) data = add_cyclic_point(np.random.random((len(lats),len(lons)-1))) fig, ax = define_map() plt.contour(lons,lats,data,5,transform=ccrs.platecarree(), cmap=plt.cm.blues) plt.colorbar(fraction=0.05, shrink=0.9) plt.show()
how do cartopy contour plot properly? also, why contours show transform=ccrs.platecarree()
, not transform=ccrs.northpolarstereo()
?
apparently add_cyclic_point
function data; contour routine treats 0 different 360. simple fix set
lons = np.arange(0,360,5)
Comments
Post a Comment