python matplotlib axes3d线交叉忽略深度

时间:2018-04-07 13:28:13

标签: python matplotlib

当在3D中绘制几条线时,最后一条线总是覆盖普遍绘制的线,即使它在它后面。

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

    def sinus(t,a,n):
            y = [1.0*a*np.sin(2.0*np.pi*t*n+0),1.0*a*np.sin(2.0*np.pi*t*n+2.0*np.pi/3),1.0*a*np.sin(2.0*np.pi*t*n+4.0*np.pi/3)]
            z = [1.0*a*np.cos(2.0*np.pi*t*n+0),1.0*a*np.cos(2.0*np.pi*t*n+2.0*np.pi/3),1.0*a*np.cos(2.0*np.pi*t*n+4.0*np.pi/3)]
            return y,z

    t = np.linspace(0,1,1e6)
    Y,Z = sinus(t,2,2)

    fig = plt.figure()
    ax = Axes3D(fig)
    for i in range(0,len(Y)):
            print(i,len(Y))
            ax.plot(t, Y[i],zs=Z[i],linewidth=4.0)
    plt.show()

resulting plot中,红线总是覆盖蓝线或绿线,即使它应该在它后面传递。预期的行为就像this。如何用python实现这一目标?

0 个答案:

没有答案