颜色贴图上的轮廓:不连续(Python)

2024-10-04 05:31:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python制作了一些彩色地图。我想在上面加上一些陆地模型。它只包含1或0,1代表土地,0代表没有土地。 等高线图上写着一些奇怪的字符。这里有人知道我如何让轮廓连接到它自己,这样它就平滑了,而不是在每一行的两端被那些奇怪的小字符打断?在

图如下:enter image description here

这是一段代码(注意这个地图是包含其他地图的绘图的一部分,所以这是索引9的地图)。在

lsmfile = netcdf.netcdf_file("/Volumes/LaCie/Plasim/Earth2/high/1367/SOL1367earth050.nc","r")
lat = lsmfile.variables["lat"].data
lon = lsmfile.variables["lon"].data
mask = lsmfile.variables["lsm"].data
mask = mask[0]
cmap = plt.get_cmap('bwr')

fig, ax = plt.subplots(nrows=5,ncols=2,figsize=(16,14))
im9 = ax.flat[9].pcolormesh(lon, lat, surfalbearth, cmap=cmap,norm=norm)
fig.colorbar(im9, ax=ax.flat[9])
ax.flat[9].set_xlim(xmin=0, xmax=355)
ax.flat[9].set_ylim(ymin=-86, ymax=86)
CS = plt.contour(lon,lat,mask, 1,colors='k')
plt.clabel(CS, fontsize=3, inline=1)

fig.tight_layout() 
plt.savefig('Maps')
plt.show()

Tags: data地图figplt代表maskvariablesax