1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
   | import numpy as np 
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
 
from random import uniform, randint
 
###############################################
# The problem is that i cannot generate bars  #
# at every square from the display: only at   #
# the diagonal.                               #
###############################################
 
fig = plt.figure()   
 
subplot = fig.gca(projection="3d")
 
X = np.linspace(0, 25, 25)  # Generate 25 points in range 0-25.
Y = np.linspace(0, 25, 25)  # Generate 25 points in range 0-25.
Z = np.linspace(0 ,25, 25)  # Generate 25 points in range 0-25.
 
 
 
dx = []
dy = []
dz = []
 
for v in range(0, 26) :
 
  dx.append(1)  # If i set another value bigger than 1 the bar width,height is not uniform to the scalar.
  dy.append(1)  # If i set another value bigger than 1 the bar width,height is not uniform to the scalar.
 
  dz.append(randint(0,70)) # Setting the bar height.
 
 
 
 
subplot.bar3d(X, Y, Z, dx, dy, dz)
 
subplot.set_xticks([])  # X axes values marks.
subplot.set_yticks([])  # Y axes values marks.
 
 
plt.show()  | 
Partager