Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from matplotlib import cm
  4. from mpl_toolkits.mplot3d import Axes3D
  5. from matplotlib.ticker import LinearLocator, FormatStrFormatter
  6.  
  7. fig = plt.figure(figsize=(20, 15))
  8. ax = fig.gca(projection = '3d')
  9. # Set rotation angle to 30 degrees
  10. ax.view_init(azim=30)
  11.  
  12. X = np.arange(0, 3, 0.1)
  13. Y = np.arange(0, 3, 0.1)
  14. X, Y = np.meshgrid(X, Y)
  15. Z = np.exp(-X**2)*np.log(1 + Y**2)
  16.  
  17. # Plot the surface.
  18. surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,linewidth=0, antialiased=False)
  19. ax.set_xlabel('X', fontsize = 20)
  20. ax.set_ylabel('Y', fontsize = 20)
  21. ax.set_zlabel('KL (X, Y)', fontsize = 20)
  22. ax.set_zlim(0, 2.2)
  23. ax.zaxis.set_major_locator(LinearLocator(10))
  24. ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
  25. fig.colorbar(surf, shrink=0.5, aspect=5)
  26. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement