为什么matplotlib的contour
和{
我有一些数据想用matplotlib basemap工具箱的赤平投影绘制在地图上。当我用填充轮廓绘制数据时,contourf
,我看到了下面的第一张图片。注意北美大部分地区的红色(正值)。当我将contourf
更改为contour
时,我看到了下面的第二张图片。注意北美中部的蓝色条纹(负值)。在
带蓝色的contour
结果是数据中的实际内容,因此我期望看到的是什么。结果并不是我所期望的。是什么原因造成的?在
{a2}
下面复制python代码。这里data
是一个大小为(73144)的float32ndarray,lon
是一个大小为(144,)的float32ndarray,lat
是一个大小为(73,)的float32ndarray。data
是在经纬度为2.5度的网格上计算的NCEP温度异常数据。在
import numpy as np
import matplotlib.pyplot as plt
# ...read data, lon, and lat from file here...
m = Basemap(width=10000000,height=6000000,
resolution='l',projection='stere',\
lat_ts=50,lat_0=50,lon_0=253)
m.drawcoastlines()
lon2d, lat2d = np.meshgrid(lon,lat)
x, y = m(lon2d,lat2d)
mymap = plt.contourf(x,y,data,levels=np.arange(17)-8,cmap=plt.cm.bwr)
plt.colorbar(mymap,orientation='vertical',shrink=0.75)
plt.show()
目前没有回答
相关问题 更多 >
编程相关推荐