cs1 = ax.contourf(lon, lat, t, levels=[1.5,5,10],zorder=1,hatches=['..', None],colors="none", transform=ccrs.PlateCarree())
时间: 2024-03-19 11:40:00 浏览: 18
这段代码使用Matplotlib中的ax.contourf函数绘制经纬度网格(lon, lat)上的温度(t)等值线图。其中levels参数指定等值线的数值,zorder参数指定图层顺序,hatches参数指定填充样式,colors参数指定填充颜色,transform参数指定坐标系转换方式。具体来说,该代码绘制了三条等值线,数值分别为1.5、5和10,其中第一条等值线采用“..”样式填充,其余两条等值线不填充,颜色均为透明。该图形使用了PlateCarree投影方式,表示平面上的经纬度坐标。
相关问题
h=ax.contourf(lon,lat,rp1,cmap='Blues', transform=ccrs.PlateCarree())改成红绿渐变
将 `cmap='Blues'` 改为 `cmap='RdYlGn'` 即可将颜色映射改为红绿渐变。修改后的代码如下:
```python
h = ax.contourf(lon, lat, rp1, cmap='RdYlGn', transform=ccrs.PlateCarree())
```
h=ax.contourf(lon,lat,rp1,cmap='RdYlGn', transform=ccrs.PlateCarree())怎么在画图时剔除缺测值
你可以使用numpy的ma.masked_where()函数来将缺测值剔除。例如,如果你的rp1数组中的缺测值为-999,你可以这样写:
```python
import numpy as np
# 将缺测值设为np.nan
rp1[rp1==-999] = np.nan
# 使用ma.masked_where()函数剔除缺测值
rp1_masked = np.ma.masked_where(np.isnan(rp1), rp1)
# 画图
h = ax.contourf(lon, lat, rp1_masked, cmap='RdYlGn', transform=ccrs.PlateCarree())
```
这样,rp1数组中的缺测值就会被剔除,并且不会在画图中显示出来。