-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDipolo_electrico_2D_3D_4D.py
49 lines (33 loc) · 1002 Bytes
/
Dipolo_electrico_2D_3D_4D.py
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
#GRAFICA DIPOLO ELECTRICO 3DB
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
theta = np.arange(0., 2., 0.005)*np.pi
Color=["#82FA58","#82FA58","#64FE2E","#3ADF00","#31B404","#298A08","#21610B","#21610B","#21610B","#21610B","#21610B"]
def main():
grafica3d()
def grafica3d():
fig = plt.figure(figsize=(10,5))
ax = fig.add_subplot(1,2,1,projection='3d')
u = np.linspace(0, 4 * np.pi, 700)
v = np.linspace(-np.pi, np.pi, 700)
u, v = np.meshgrid(u, v)
r = (np.abs(np.sin(u)+np.pi/2))**2
x = r*(np.sin(u) * np.cos(v))
y = r*(np.sin(u) * np.sin(v))
z = r*(np.cos(u))
plt.title('Dipolo 3D')
ax.plot_surface(x, y, z, color='#3ADF00')
ax.view_init(45,45)
plt.subplot(1,2,2)
grafica2d()
def grafica2d():
for i in range(1,9):
r=i*(np.sin(theta+(np.pi/2)))**2
c=plt.subplot(122, polar=True)
c.plot(theta,r,Color[i], linewidth=1.5)
plt.title('Dipolo 2D')
plt.show()
if __name__ == '__main__':
main()