diff options
| author | chzhang <zch921005@126.com> | 2023-01-11 22:51:51 +0800 |
|---|---|---|
| committer | chzhang <zch921005@126.com> | 2023-01-11 22:51:51 +0800 |
| commit | d7f38501d9d3a6c5b01054d5cb7499eb38b4acab (patch) | |
| tree | 7c5188129342f911300e835d1d881ef328262211 /vis/animation/tutorials | |
| parent | 1257c68e9c1e8e4bad430a89e53826a239687a84 (diff) | |
hill climbing
Diffstat (limited to 'vis/animation/tutorials')
| -rw-r--r-- | vis/animation/tutorials/z_f_x_y.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vis/animation/tutorials/z_f_x_y.py b/vis/animation/tutorials/z_f_x_y.py new file mode 100644 index 0000000..845db0c --- /dev/null +++ b/vis/animation/tutorials/z_f_x_y.py @@ -0,0 +1,27 @@ +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.ticker import MaxNLocator +from matplotlib import cm + +landscape = np.random.randint(1, high=50, size=(10, 10)) + +xs, ys = np.meshgrid(range(10), range(10)) + +# zs = landscape[xs, ys] +zs = (xs-4)**2 + (ys-3)**2 +fig = plt.figure() +ax = fig.add_subplot(111, projection='3d') + +surf = ax.plot_surface(xs, ys, zs, rstride=1, cstride=1, cmap=cm.jet, linewidth=0) +fig.colorbar(surf) + +title = ax.set_title("plot_surface: given X, Y and Z as 2D:") +title.set_y(np.max(zs)+0.01) + +# ax.xaxis.set_major_locator(MaxNLocator(5)) +# ax.yaxis.set_major_locator(MaxNLocator(6)) +# ax.zaxis.set_major_locator(MaxNLocator(5)) + +fig.tight_layout() + +plt.show() |
