forked from exo7math/deepmath-exo7
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonxy_matplolib_2.py
More file actions
88 lines (58 loc) · 1.69 KB
/
pythonxy_matplolib_2.py
File metadata and controls
88 lines (58 loc) · 1.69 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# Fig 1. Bosse - grillage
n = 20
VX = np.linspace(-3.0, 3.0, n)
VY = np.linspace(-3.0, 3.0, n)
X,Y = np.meshgrid(VX, VY)
# def f(x,y):
# z = 1/(2+x**2+y**2)
# return z
# Z = f(X,Y)
# fig = plt.figure()
# ax = plt.axes(projection='3d')
# ax.view_init(40, -70)
# ax.plot_wireframe(X, Y, Z)
# plt.savefig('pythonxy-surface-1.png')
# Fig 2. Quart de plans - hot
# n = 25
# VX = np.linspace(-3.0, 3.0, n)
# VY = np.linspace(-3.0, 3.0, n)
# X,Y = np.meshgrid(VX, VY)
# def f(x,y):
# return np.absolute(x)+np.absolute(y)
# Z = f(X,Y)
# fig = plt.figure()
# ax = plt.axes(projection='3d')
# ax.view_init(40, -70)
# ma_surface = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='hot', edgecolor='none')
# fig.colorbar(ma_surface)
# plt.savefig('pythonxy-surface-2.png')
# Fig 3. sin(r) # couleur
n = 50
VX = np.linspace(-6.0, 6.0, n)
VY = np.linspace(-6.0, 6.0, n)
X,Y = np.meshgrid(VX, VY)
def f(x,y):
r = np.sqrt(x**2+y**2)
z = np.sin(r)
return z
Z = f(X,Y)
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.view_init(40, -120)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='viridis', edgecolor='none')
# plt.savefig('pythonxy-surface-3.png')
# ax.view_init(45, -70)
# ax.plot_wireframe(X, Y, Z)
# ax.plot_surface(X, Y, Z)
# ax.plot_surface(X, Y, Z, rstride=1, cstride=1,
# cmap='hot', edgecolor='none')
# cmap='binary'
# cmap='viridis'
# ax.contour(X, Y, Z, colors='black', linewidths=3)
# ma_surface = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='hot', edgecolor='none',alpha=0.5)
# ax.contour(X, Y, Z, zdir='z', offset=-2, cmap='hot')
# fig.colorbar(ma_surface);
plt.show()