Created
February 27, 2020 05:02
-
-
Save flymin/bb7caa9859712c31b18dd185a0c1a1f0 to your computer and use it in GitHub Desktop.
[surface plot] draw a surface using matplotlib #python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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