colored wireframe plot in matplotlib

前端 未结 3 1539
半阙折子戏
半阙折子戏 2021-01-04 03:05

I am trying to color a wireframe plot according to the z-value. I can\'t find any code examples on the internet.

Here is an example of a surface plot that has the co

3条回答
  •  长发绾君心
    2021-01-04 03:31

    Maybe you need to use plot_surface instead?

    import matplotlib.pylab as plt
    from matplotlib import cm 
    from mpl_toolkits.mplot3d import Axes3D
    
    fig = plt.figure(figsize=(8, 8))
    ax = fig.gca(projection='3d')
    
    t = np.linspace(-3, 2, 31)
    s = np.linspace(-3, 2, 31)
    
    T, S = np.meshgrid(t, s)
    
    ax.plot_surface(T * T, sqrt2 * T * S, S * S, cmap=cm.jet, rstride=1, cstride=1)
    
    ax.set_xlabel('$t^2$')
    ax.set_ylabel('$\sqrt{2} s t$')
    ax.set_zlabel('$s^2$')
    
    ax.set_title('line $s = t$ in $\cal F$')
    
    plt.show()
    

    enter image description here

提交回复
热议问题