【问题标题】:I want to plot a 2d surface on a 3d basemap in python我想在 python 中的 3d 底图上绘制 2d 表面
【发布时间】:2021-06-30 04:10:37
【问题描述】:

我有一个以高度和纬度为维度的垂直数据集。我想将它垂直绘制在底图上like this。我的数据是这样的vertical surface

数据可以从我的githttps://github.com/kmmrao/3dplot_with_2d_surface.git获取

【问题讨论】:

    标签: 3d matplotlib-basemap


    【解决方案1】:

    我通过结合以下方法找到了解决方案:

    将 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()
    

    【讨论】:

    • 你能帮帮我吗?
    猜你喜欢
    • 2015-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 2015-09-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多