[Python] How to plot data with Axes3D in python?

Discussão em 'Python' iniciado por Stack, Junho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I need to plot data by using Axes3D of python. This is my code:

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

    x = [74, 74, 74, 74, 74, 74, 74, 74, 192, 74]
    y = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    z = [1455, 1219, 1240, 1338, 1276, 1298, 1292, 1157, 486, 1388]
    dx = np.ones(10)
    dy = np.ones(10)
    dz = [0,1,2,3,4,5,6,7,8,9]


    fig = plt.figure()
    ax = Axes3D(fig)
    ax.bar3d(x, y, z, dx, dy, dz, color='#00ceaa')
    ax.w_xaxis.set_ticklabels(x)
    ax.w_yaxis.set_ticklabels(y)
    ax.set_title("Data Analysis ")
    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_zlabel('z')


    plt.show()


    [​IMG]

    My problem is that I expect to have a large bars that must look like histogram. But I don't have that result, That means it looks like this:

    [​IMG]

    What must I change in my code to have a figure like the second figure please?

    Continue reading...

Compartilhe esta Página