【发布时间】:2021-06-30 04:10:37
【问题描述】:
我有一个以高度和纬度为维度的垂直数据集。我想将它垂直绘制在底图上like this。我的数据是这样的vertical surface
数据可以从我的githttps://github.com/kmmrao/3dplot_with_2d_surface.git获取
【问题讨论】:
标签: 3d matplotlib-basemap
我有一个以高度和纬度为维度的垂直数据集。我想将它垂直绘制在底图上like this。我的数据是这样的vertical surface
数据可以从我的githttps://github.com/kmmrao/3dplot_with_2d_surface.git获取
【问题讨论】:
标签: 3d matplotlib-basemap
我通过结合以下方法找到了解决方案:
将 matplotlib.pyplot 导入为 plt 将 numpy 导入为 np
fig = plt.figure() ax = fig.add_subplot(projection='3d') yticks = [3, 2, 1, 0] X,Z = np.meshgrid(np.linspace(0,1,21), np.linspace(0,1,21)) data = np.cos(X) * np.cos(X) + np.sin(Z) * np.sin(Z) for c, k in zip(colors, yticks): Y = k*np.ones(X.shape) ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=plt.cm.BrBG(data/data.max()), shade=False) ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') ax.set_yticks(yticks) plt.show()
【讨论】: