Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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()
Unfortunately you can't currently get transparent bars in any matplotlib version >=2 (Issue #10237).
Apart, the problem is that you got the role of x,y,z and dx, dy, dz wrong somehow. I suppose you meant something like
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 = np.zeros(10)
dx = np.ones(10)*10
dy = np.ones(10)
dz = [1455, 1219, 1240, 1338, 1276, 1298, 1292, 1157, 486, 1388]
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
bar3d = ax.bar3d(x, y, z, dx, dy, dz, color='C0')
ax.set_title("Data Analysis ")
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.