File tree Expand file tree Collapse file tree 1 file changed +19
-21
lines changed Expand file tree Collapse file tree 1 file changed +19
-21
lines changed Original file line number Diff line number Diff line change 1
- #!/usr/bin/env python
2
1
"""
3
2
Example: simple line plots with NaNs inserted.
4
3
"""
5
- from pylab import *
6
4
import numpy as np
5
+ import matplotlib .pyplot as plt
7
6
8
- t = arange (0.0 , 1.0 + 0.01 , 0.01 )
9
- s = cos (2 * 2 * pi * t )
10
- t [41 :60 ] = NaN
11
- #t[50:60] = np.inf
7
+ t = np .arange (0.0 , 1.0 + 0.01 , 0.01 )
8
+ s = np .cos (2 * 2 * np .pi * t )
9
+ t [41 :60 ] = np .nan
12
10
13
- subplot (2 , 1 , 1 )
14
- plot (t , s , '-' , lw = 2 )
11
+ plt . subplot (2 , 1 , 1 )
12
+ plt . plot (t , s , '-' , lw = 2 )
15
13
16
- xlabel ('time (s)' )
17
- ylabel ('voltage (mV)' )
18
- title ('A sine wave with a gap of NaNs between 0.4 and 0.6' )
19
- grid (True )
14
+ plt . xlabel ('time (s)' )
15
+ plt . ylabel ('voltage (mV)' )
16
+ plt . title ('A sine wave with a gap of NaNs between 0.4 and 0.6' )
17
+ plt . grid (True )
20
18
21
- subplot (2 , 1 , 2 )
22
- t [0 ] = NaN
23
- t [- 1 ] = NaN
24
- plot (t , s , '-' , lw = 2 )
25
- title ('Also with NaN in first and last point' )
19
+ plt . subplot (2 , 1 , 2 )
20
+ t [0 ] = np . nan
21
+ t [- 1 ] = np . nan
22
+ plt . plot (t , s , '-' , lw = 2 )
23
+ plt . title ('Also with NaN in first and last point' )
26
24
27
- xlabel ('time (s)' )
28
- ylabel ('more nans' )
29
- grid (True )
25
+ plt . xlabel ('time (s)' )
26
+ plt . ylabel ('more nans' )
27
+ plt . grid (True )
30
28
31
- show ()
29
+ plt . show ()
You can’t perform that action at this time.
0 commit comments