如何依赖铸造值的3D绘图线颜色?

时间:2015-06-18 17:42:13

标签: python matplotlib

我已经将Matplotlib plot pulse propagation in 3d的解决方案应用到我的需求中,并且由于此操作,我得到的情节如下所示:

enter image description here

然而,在上面链接的问题中,stack-user引用了这样的情节:

enter image description here

如何在我的绘图上为线条着色,以便更高的值将关闭为红色,将较低的值设置为蓝色?

这是我的代码,包含一些随机数据:

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D


def draw_3d_plot(x_scale, y_scale, data):
    sx = x_scale.size
    sy = y_scale.size

    x_scale = np.tile(x_scale, (sy, 1))
    y_scale = np.tile(y_scale, (sx, 1)).T

    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1, projection='3d')
    surf = ax.plot_wireframe(x_scale, y_scale, data, cstride=1000)

draw_3d_plot(np.arange(1000), np.linspace(1, 3, 3), np.random.rand(3, 1000))
plt.show()

0 个答案:

没有答案