Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 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.001)
  13. Y = np.arange(0, 3, 0.001)
  14. X, Y = np.meshgrid(X, Y)
  15. Z = np.exp(-X**2)*np.log(1 + Y**2) + (1 - np.exp(-X**2))*np.log((1 + Y**2) / (Y**2+0.01))
  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('CE (X, Y)', fontsize = 20)
  22. ax.set_zlim(0, 4.3)
  23. ax.zaxis.set_major_locator(LinearLocator(10))
  24. ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
  25.  
  26. # Add a color bar which maps values to colors.
  27. fig.colorbar(surf, shrink=0.5, aspect=5)
  28. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement