这里是我的问题。
- 地形是通过这些区域的海拔高度来表示的。我已经上传了这里
现在,我可以使用matplotlib中的contourf将地形绘制为背景。
fig =plt.figure(figsize=(10,8))
ax = plt.subplot()
xi,yi = np.linspace(195.2260,391.2260,50), np.linspace(4108.9341,4304.9341,50)
height = np.array(list(csv.reader(open("terr_grd.csv","rb"),delimiter=','))).astype('float')
terrf = plt.contourf(xi, yi, height,15, cmap=plt.cm.Blues)
terr = plt.contour(xi, yi, height, 15,
colors='k',alpha=0.5)
plt.clabel(terr, fontsize=9, inline=1)
http://i13.tietuku.com/1d32bfe631e20eee.png
作为背景,它可能会影响覆盖图层(不同颜色混合在一起)。
我在一本书上找到的下面上传的图片是一个很好的可视化艺术品。
http://i11.tietuku.com/4d4178c16eb7aaf6.png
地形作为背景对于叠加的流域(绿色)没有任何影响。
因此,如何使用 matplotlib 绘制这种类似的阴影地形,我尝试了一些色图,但我无法获得类似的绘图。
更新
我已经尝试了下面代码中的 alpha 设置:
# Z is 2-d array represent the value of each grid
CS = plt.contourf(xi,yi, Z,2, cmap=plt.cm.Greens,
vmax=abs(Z).max(), vmin=abs(Z).min(),alpha=0.8,zorder = 3)
图像如下: 无论我使用何种数据,与流域面积无关。我致力于像我在此处发布的图2一样更加真实地描绘地形起伏。