3
3
Step Demo
4
4
=========
5
5
6
- Example step plots.
6
+ This example demonstrates the use of `.pyplot.step` for piece-wise constant
7
+ curves. In particular, it illustrates the effect of the parameter *where*
8
+ on the step position.
9
+
10
+ The circular markers created with `.pyplot.plot` show the actual data
11
+ positions so that it's easier to see the effect of *where*.
12
+
7
13
"""
8
14
import numpy as np
9
15
from numpy import ma
10
16
import matplotlib .pyplot as plt
11
17
12
- x = np .arange (1 , 7 , 0.4 )
13
- y0 = np .sin (x )
14
- y = y0 .copy () + 2.5
18
+ x = np .arange (0 , 14 )
19
+ y = np .sin (x / 2 )
15
20
16
- plt .step (x , y , label = 'pre (default)' )
21
+ plt .step (x , y + 2 , label = 'pre (default)' )
22
+ plt .plot (x , y + 2 , 'C0o' , alpha = 0.5 )
17
23
18
- y -= 0.5
19
- plt .step (x , y , where = 'mid ' , label = 'mid' )
24
+ plt . step ( x , y + 1 , where = 'mid' , label = 'mid' )
25
+ plt .plot (x , y + 1 , 'C1o ' , alpha = 0.5 )
20
26
21
- y -= 0.5
22
27
plt .step (x , y , where = 'post' , label = 'post' )
28
+ plt .plot (x , y , 'C2o' , alpha = 0.5 )
23
29
24
- y = ma .masked_where ((y0 > - 0.15 ) & (y0 < 0.15 ), y - 0.5 )
25
- plt .step (x , y , label = 'masked (pre)' )
26
-
27
- plt .legend ()
28
-
29
- plt .xlim (0 , 7 )
30
- plt .ylim (- 0.5 , 4 )
31
-
32
- plt .show ()
30
+ plt .legend (title = 'Parameter where:' )
31
+ plt .show ()
0 commit comments