Advertisement
Guest User

Untitled

a guest
Mar 19th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import numpy as np
  2. from mpl_toolkits.mplot3d import Axes3D
  3. import matplotlib.pyplot as plt
  4. import numpy as np
  5.  
  6.  
  7. ### NOTE: make one of these an exact density or KDE to exactly match your plot intention.
  8. randns1 = np.random.normal(size=10000)
  9. counts1, bins1 = np.histogram(randns1, bins=30)
  10.  
  11. randns2 = np.random.normal(size=10000)
  12. counts2, bins2 = np.histogram(randns2, bins=30)
  13.  
  14.  
  15. data = np.array([counts1,counts2])
  16.  
  17. ## other data
  18. fig = plt.figure()
  19. ax = fig.add_subplot(111, projection='3d')
  20. colors = ["r","g","b"]*10
  21.  
  22. ## Draw 3D hist
  23. ncnt, nbins = data.shape[:2]
  24. xs_new = np.arange(-3,3,6/30)
  25. for i in range(ncnt):
  26. ys = data[i]
  27. cs = [colors[i]] * nbins
  28. ax.bar(xs_new, ys.ravel(), zs=i, zdir='x', color=cs, alpha=0.8)
  29. ax.set_axis_off()
  30.  
  31.  
  32. x = np.linspace(0, 1, 1000)
  33. y = randns1[::10]
  34. ax.plot(x, y, zs=0, zdir='z', label='curve in (x,y)')
  35.  
  36.  
  37. # ax.set_xlabel('idx')
  38. # ax.set_ylabel('bins')
  39. # ax.set_zlabel('nums')
  40. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement