forked from exo7math/deepmath-exo7
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradient_surface_5.py
More file actions
44 lines (29 loc) · 836 Bytes
/
gradient_surface_5.py
File metadata and controls
44 lines (29 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# Partie A - ligne de niveaux
n = 50
VX = np.linspace(-1.0, 1.0, n)
VY = np.linspace(-1.0, 1.0, n)
X,Y = np.meshgrid(VX, VY)
def f(x,y): # from matlab website
z = x**2 + y**2
return z
Z = f(X,Y)
fig = plt.figure()
ax = plt.axes(projection='3d')
# Partie A - Surface
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='viridis', edgecolor='none',alpha=1)
# Partie B - Opposé du gradients
n = 10
VX = np.linspace(-1.0, 1.0, n)
VY = np.linspace(-1.0, 1.0, n)
U,V = np.meshgrid(VX, VY)
# q = ax.quiver(VX, VY, -U, -V)
# # ax.quiverkey(q, X=0.3, Y=1.1, U=10,
# label='Quiver key, length = 10', labelpos='E')
ax.view_init(15, -60)
plt.axis('off')
plt.tight_layout()
# plt.savefig('gradient-surface-5c.png')
plt.show()