Python数据分析、展示

来源:互联网 发布:mysql存放byteImage 编辑:程序博客网 时间:2024/05/18 18:55

代码

from mpl_toolkits.mplot3d import Axes3Dimport matplotlib.pyplot as pltimport numpy as npfig = plt.figure()ax = fig.add_subplot(111, projection='3d')Z=['Room3-window', 'Veranda-door', 'Living-center', 'Couch-side', 'Living-window', 'Room1-door', 'Kitchen-center', 'Restroom2-door', 'Room3-door', 'Enter-door', 'Room2-middle', 'Sofa-center', 'Room3-middle', 'Powder-door', 'Room1-middle', 'Restroom1-door', 'TV-front', 'TV-Sofa-middle', 'Sofa-side', 'Room2-door', 'Kitchen-window', 'Room1-window', 'Room2-window']X=[[-79.0, -78.0, -76.0, -75.0, -74.0, -73.0, -71.0, -70.0, -69.0, -68.0, -67.0], [-48.0, -53.0, -51.0, -50.0, -49.0], [-44.0, -43.0, -40.0, -39.0, -38.0, -37.0], [-47.0, -46.0, -45.0, -44.0, -43.0, -42.0], [-55.0, -54.0, -53.0, -52.0, -51.0, -50.0, -49.0], [-55.0, -53.0, -52.0, -51.0, -50.0, -48.0, -47.0, -46.0, -45.0, -44.0], [-58.0, -57.0, -56.0, -55.0, -54.0, -53.0, -52.0, -51.0], [-64.0, -72.0, -69.0, -68.0, -67.0, -66.0, -65.0], [-64.0, -63.0, -62.0, -61.0, -60.0, -66.0, -65.0], [-64.0, -63.0, -62.0, -61.0, -60.0, -59.0, -58.0, -57.0, -56.0, -55.0], [-64.0, -63.0, -62.0, -61.0, -60.0, -59.0, -57.0, -67.0, -66.0, -65.0], [-48.0, -47.0, -46.0, -45.0, -44.0, -43.0], [-64.0, -63.0, -62.0, -61.0, -68.0, -67.0, -66.0, -65.0], [-56.0, -61.0, -59.0, -58.0, -57.0], [-52.0, -51.0, -49.0, -47.0, -46.0, -45.0], [-64.0, -63.0, -62.0, -61.0, -60.0, -59.0, -58.0, -57.0, -56.0, -55.0, -54.0, -53.0, -52.0, -51.0, -50.0], [-43.0, -42.0, -41.0, -40.0, -39.0, -38.0, -37.0, -36.0], [-41.0, -40.0, -39.0, -38.0, -37.0, -36.0], [-55.0, -54.0, -53.0, -52.0, -51.0, -50.0, -49.0, -48.0, -47.0], [-60.0, -59.0, -58.0, -57.0, -56.0, -55.0, -54.0, -53.0, -51.0], [-61.0, -60.0, -58.0, -57.0, -56.0, -54.0], [-61.0, -59.0, -58.0, -57.0, -56.0, -55.0, -54.0, -53.0], [-63.0, -62.0, -74.0, -72.0, -71.0, -70.0, -69.0, -68.0]]Y=[[3, 1, 1, 1, 1, 1, 2, 3, 3, 3, 1], [5, 5, 6, 1, 3], [3, 1, 11, 1, 3, 1], [5, 3, 4, 2, 4, 2], [1, 3, 4, 2, 4, 5, 1], [1, 1, 2, 1, 1, 3, 5, 3, 2, 1], [1, 4, 3, 2, 3, 3, 2, 2], [2, 3, 2, 1, 6, 5, 1], [2, 3, 3, 5, 3, 2, 2], [1, 2, 2, 1, 2, 2, 6, 6, 2, 2], [3, 5, 5, 5, 4, 1, 1, 2, 1, 1], [7, 3, 4, 2, 3, 1], [5, 3, 3, 2, 2, 1, 2, 2], [3, 1, 5, 6, 5], [2, 2, 5, 5, 4, 2], [2, 2, 2, 1, 2, 1, 2, 9, 1, 1, 1, 1, 2, 2, 1], [1, 2, 7, 3, 1, 3, 1, 2], [2, 1, 7, 4, 5, 1], [1, 2, 3, 1, 1, 1, 4, 4, 3], [1, 1, 1, 5, 1, 2, 8, 8, 1], [5, 6, 3, 3, 2, 1], [1, 1, 3, 1, 2, 5, 5, 2], [1, 1, 1, 3, 4, 7, 2, 1]]for c, z, t in zip(['r', 'g', 'b', 'y','r', 'g', 'b', 'y','r', 'g', 'b', 'y','r', 'g', 'b', 'y','r', 'g', 'b', 'y','r', 'g', 'b'], [0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230], range(0,len(X))):    xs = X[t]    ys = Y[t]    cs = [c] * len(xs)    ax.bar(xs, ys, zs=z, zdir='y', color=cs, alpha=0.8)ax.set_xlabel('X')ax.set_ylabel('y')ax.set_zlabel('Z')plt.zticks(z,)plt.show()

结果


0 0