File tree 1 file changed +18
-21
lines changed
1 file changed +18
-21
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
- ==============
3
- Animation Demo
4
- ==============
2
+ ================
3
+ pyplot animation
4
+ ================
5
5
6
- Pyplot animation example .
6
+ Generating an animation by calling `~.pyplot.pause` between plotting commands .
7
7
8
- The method shown here is only for very simple, low-performance
9
- use. For more demanding applications, look at the animation
10
- module and the examples that use it.
8
+ The method shown here is only suitable for simple, low-performance use. For
9
+ more demanding applications, look at the :mod:`animation` module and the
10
+ examples that use it.
11
+
12
+ Note that calling `time.sleep` instead of `~.pyplot.pause` would *not* work.
11
13
"""
12
14
13
15
import matplotlib .pyplot as plt
14
16
import numpy as np
15
17
16
- x = np .arange (6 )
17
- y = np .arange (5 )
18
- z = x * y [:, np .newaxis ]
18
+ np .random .seed (19680801 )
19
+ data = np .random .random ((50 , 50 , 50 ))
19
20
20
- for i in range (5 ):
21
- if i == 0 :
22
- p = plt .imshow (z )
23
- fig = plt .gcf ()
24
- plt .clim () # clamp the color limits
25
- plt .title ("Boring slide show" )
26
- else :
27
- z = z + 2
28
- p .set_data (z )
21
+ fig , ax = plt .subplots ()
29
22
30
- print ("step" , i )
31
- plt .pause (0.5 )
23
+ for i in range (len (data )):
24
+ ax .cla ()
25
+ ax .imshow (data [i ])
26
+ ax .set_title ("frame {}" .format (i ))
27
+ # Note that using time.sleep does *not* work here!
28
+ plt .pause (0.1 )
You can’t perform that action at this time.
0 commit comments