Skip to content

Instantly share code, notes, and snippets.

@flymin
Created February 27, 2020 05:02
Show Gist options
  • Select an option

  • Save flymin/bb7caa9859712c31b18dd185a0c1a1f0 to your computer and use it in GitHub Desktop.

Select an option

Save flymin/bb7caa9859712c31b18dd185a0c1a1f0 to your computer and use it in GitHub Desktop.
[surface plot] draw a surface using matplotlib #python
from matplotlib import pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(0, 1, 0.05)
Y = np.arange(0, 1, 0.05)
X, Y = np.meshgrid(X, Y)
#F1
Z = (2 * X * Y) / (X + Y)
Z[0][0] = 0
# #AVG
# Z = (X + Y) / 2
# #GEO AVG
# Z = np.sqrt(X * Y)
# 具体函数方法可用 help(function) 查看,如:help(ax.plot_surface)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='rainbow')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment