MCPcopy Create free account
hub / github.com/Apress/python-for-matlab-development / circle_to_ellipse

Function circle_to_ellipse

code/plots/circle_ellipse.py:34–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32import matplotlib.pyplot as plt
33from matplotlib.animation import FuncAnimation
34def circle_to_ellipse():
35 fig, ax = plt.subplots()
36 T = np.linspace(0, 2*np.pi, 200)
37 x = np.cos(T)
38 y = np.sin(T)
39 curve, = plt.plot(x,y,'b')
40 A_values = np.hstack([np.linspace(0.1, 0.9, 100),
41 np.linspace(0.9, 0.1, 100)])
42 def init():
43 ax.set_xlim(-1, 1)
44 ax.set_ylim(-1, 1)
45 ax.set_aspect('equal')
46 return curve,
47 def update(A):
48 x = A*np.cos(T)
49 y = np.sin(T)
50 curve, = plt.plot(x,y,'b')
51 return curve,
52 ani = FuncAnimation(fig, update, A_values,
53 interval=20, # milliseconds
54 init_func=init, blit=True)
55 plt.show()
56
57circle_to_ellipse()

Callers 1

circle_ellipse.pyFile · 0.85

Calls 1

showMethod · 0.80

Tested by

no test coverage detected