Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. from mpl_toolkits import mplot3d
  4. from matplotlib.ticker import LinearLocator, FormatStrFormatter
  5. def f(x, y):
  6.     return (x**3+x**2+y**2++2*x*y+-10*x+2*y)
  7.  
  8. x = np.linspace(-6, 6, 20)
  9. y = np.linspace(-6, 6, 20)
  10. X, Y = np.meshgrid(x, y)
  11. Z = f(X, Y)
  12.  
  13.  
  14.  
  15.  
  16. fig = plt.figure()
  17. ax = plt.axes(projection='3d')
  18. ax.set_title('Grafiko pavadinimas');
  19. ax.set_xlabel('x asis')
  20. ax.set_ylabel('y asis')
  21. ax.set_zlabel('z asis');
  22.  
  23.  
  24. ax.view_init(10, 70)
  25. plotas = ax.plot_surface(X, Y, Z,  cmap="magma")
  26. fig.colorbar(plotas, shrink=0.5, aspect=20) #color bar properties
  27.  
  28.  
  29. ticks = np.linspace(-6,6,26)
  30. ticks2=np.linspace(-150, 300, 26)
  31. ax.set_yticks(ticks)
  32. ax.set_xticks(ticks)
  33. ax.set_zticks(ticks2)
  34. xlabels=[""]*26
  35. xlabels[25]=10
  36. xlabels[12]=0
  37. xlabels[0]=-10
  38. ylabels=[""]*26
  39. ylabels[25]=10
  40. ylabels[12]=0
  41. ylabels[0]=-10
  42. zlabels=[""]*26
  43. zlabels[0]=-100
  44. zlabels[6]=-50
  45. zlabels[25]=250
  46. zlabels[12]=0
  47. zlabels[18]=100
  48. ax.set_zticklabels(zlabels)
  49. ax.set_xticklabels(xlabels)
  50. ax.set_yticklabels(ylabels)
  51. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement