使用PyPlot的非平滑3D表面图

时间:2018-12-23 13:02:03

标签: python matplotlib graph

我正在尝试绘制这样的图形 needed plot

我想出了一个特写镜头,但是太平滑了

# Scene setup
fig = plt.figure(figsize=(12,10))
ax = fig.gca(projection='3d')
ax.view_init(40, 130)

xx, yy = np.meshgrid(np.linspace(-2, 2, 10), np.linspace(-2, 2, 10))
z = phase(activation(cm_num))

# Plot the surface.
surf = ax.plot_surface(xx, yy, z, cmap=cm.coolwarm,
                       linewidth=0, antialiased=False)

my plot

如何获得类似楼梯的形状,或者应该使用极坐标?

其他说明:z是10x10的numpy数组

array([[3.77, 3.77, 3.77, 3.77, 4.4 , 4.4 , 5.03, 5.03, 5.03, 5.03],
       [3.77, 3.77, 3.77, 3.77, 4.4 , 4.4 , 5.03, 5.03, 5.03, 5.03],
       [3.14, 3.14, 3.77, 3.77, 4.4 , 4.4 , 5.03, 5.03, 5.65, 5.65],
       [3.14, 3.14, 3.14, 3.77, 3.77, 5.03, 5.03, 5.65, 5.65, 5.65],
       [3.14, 3.14, 3.14, 3.14, 3.77, 5.03, 5.65, 5.65, 5.65, 5.65],
       [2.51, 2.51, 2.51, 2.51, 1.88, 0.63, 0.  , 0.  , 0.  , 0.  ],
       [2.51, 2.51, 2.51, 1.88, 1.88, 0.63, 0.63, 0.  , 0.  , 0.  ],
       [2.51, 2.51, 1.88, 1.88, 1.26, 1.26, 0.63, 0.63, 0.  , 0.  ],
       [1.88, 1.88, 1.88, 1.88, 1.26, 1.26, 0.63, 0.63, 0.63, 0.63],
       [1.88, 1.88, 1.88, 1.88, 1.26, 1.26, 0.63, 0.63, 0.63, 0.63]])

0 个答案:

没有答案