在3d散点图中使用3d对象作为标记 - Python

时间:2013-07-31 14:21:03

标签: python matplotlib

使用下面的代码,我试图模拟用罐子制作的碗。我希望每个标记都是一个罐头,最好的方法是什么?

我非常感谢任何建议,谢谢。

    import pylab
    import numpy as np
    from math import pi, sin, cos
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')

    numCansHigh = 24
    startCanNum = 15
    hCan = 41
    dCan = 85
    rCan = dCan/2.0

    # Rise options: 0,1,2,3

    baseRise = 3
    topRise  = 2
    changeH = 8

    z = np.linspace(0, hCan*numCansHigh, num=numCansHigh)

    n=[startCanNum]
    for i in range(1, changeH):
        n.append(n[i-1] + baseRise)
    for i in range(changeH,len(z)):
        n.append(n[i-1] + topRise)

    r = [i*rCan/(pi) for i in n]

    theta = [2*pi / a for a in n]

    totalCans = 0

    for i in range(len(z)):
        for j in range(int(n[i])):
            totalCans+=1
            x9 = r[i]*cos(j*theta[i])
            y9 = r[i]*sin(j*theta[i])
            z9 = z[i]
            ax.scatter(x9,y9,z9,s=500,marker='s')


    plt.show()

0 个答案:

没有答案