Skip to content

Commit 0027ce1

Browse files
a few examples/experimental plots
1 parent 3144000 commit 0027ce1

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import matplotlib.pyplot as plt
2+
3+
fig = plt.figure()
4+
5+
fig.patch.set_alpha(0.0)
6+
7+
ax0 = fig.add_axes( [0.1,0.1,0.8,0.8] )
8+
ax1 = fig.add_axes( [0.1,0.1,0.8,0.8] )
9+
10+
print('ax0 zorder=',ax0.get_zorder())
11+
print('ax1 zorder=',ax1.get_zorder())
12+
13+
ax0.set_zorder(0.1)
14+
15+
X = [0,1,2,3,4]
16+
17+
Y0 = [2,4,3,5,3.5]
18+
Y1 = [4600,4400,4800,4800,5000]
19+
20+
21+
ax0.plot(X, Y0, linewidth=5, color='lime')
22+
ax1.plot(X, Y1, linewidth=5, color='magenta')
23+
24+
# ax1.set_zorder(1)
25+
# ax0.set_zorder(2)
26+
# ax0.patch.set_visible(False)
27+
28+
plt.show()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
A simple example of TWO curves from one func animation
3+
"""
4+
import numpy as np
5+
import matplotlib.pyplot as plt
6+
import matplotlib.animation as animation
7+
8+
fig = plt.figure(figsize=(8*0.66,4*0.66))
9+
ax1 = fig.add_subplot(1,2,1)
10+
ax2 = fig.add_subplot(1,2,2,sharey=ax1)
11+
12+
x = np.arange(0, 2*np.pi, 0.02)
13+
14+
line1, = ax1.plot(x, np.sin(x))
15+
line2, = ax2.plot(x, 0.5*np.sin(2.5*(x)))
16+
17+
def animate(i):
18+
line2.set_ydata(0.5*np.sin(2.5*(x + i/5.0))) # update the data
19+
if i%3 == 0:
20+
line1.set_ydata(np.sin(x + i/10.0)) # update the data
21+
return line1,line2
22+
23+
ani1 = animation.FuncAnimation(fig, animate, np.arange(1, 100), interval=250)
24+
25+
# writergif = animation.PillowWriter(fps=5)
26+
# ani1.save('s2c.gif',writer=writergif)
27+
28+
plt.show()

examples/simple_multianimation.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
A simple example of TWO animated plots
3+
"""
4+
import numpy as np
5+
import matplotlib.pyplot as plt
6+
import matplotlib.animation as animation
7+
8+
fig = plt.figure()
9+
ax1 = fig.add_subplot(1,2,1)
10+
ax2 = fig.add_subplot(1,2,2,sharey=ax1)
11+
12+
x = np.arange(0, 2*np.pi, 0.01)
13+
14+
line1, = ax1.plot(x, np.sin(x))
15+
line2, = ax2.plot(x, 0.5*np.sin(2.5*(x)))
16+
17+
def animate1(i):
18+
line1.set_ydata(np.sin(x + i/10.0)) # update the data
19+
return line1,
20+
21+
def animate2(i):
22+
line2.set_ydata(0.5*np.sin(2.5*(x + i/5.0))) # update the data
23+
return line2,
24+
25+
ani1 = animation.FuncAnimation(fig, animate1, np.arange(1, 200), interval=250)
26+
27+
ani2 = animation.FuncAnimation(fig, animate2, np.arange(1, 200), interval=75)
28+
29+
plt.show()

0 commit comments

Comments
 (0)