fork download
  1. # Hello World program in Python
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. from mpl_toolkits.mplot3d import Axes3D
  5.  
  6. fig = plt.figure()
  7. ax = Axes3D(fig)
  8.  
  9. # X, Y value
  10. X = np.arange(-4, 4, 0.25)
  11. Y = np.arange(-4, 4, 0.25)
  12. X, Y = np.meshgrid(X, Y)
  13. R = np.sqrt(X ** 2 + Y ** 2)
  14. # height value
  15. Z = np.sin(R)
  16.  
  17. ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=plt.get_cmap('rainbow'))
  18.  
  19. ax.contourf(X, Y, Z, zdir='z', offset=-2, cmap=plt.get_cmap('rainbow'))
  20.  
  21.  
Success #stdin #stdout #stderr 2.16s 57932KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
./prog.py:7: MatplotlibDeprecationWarning: Axes3D(fig) adding itself to the figure is deprecated since 3.4. Pass the keyword argument auto_add_to_figure=False and use fig.add_axes(ax) to suppress this warning. The default value of auto_add_to_figure will change to False in mpl3.5 and True values will no longer work in 3.6.  This is consistent with other Axes classes.