@@ -2964,6 +2964,58 @@ def get_handles():
29642964
29652965 #### Specialized plotting
29662966
2967+ def step (self , x , y , * args , ** kwargs ):
2968+ '''
2969+ step(x, y, *args, **kwargs)
2970+
2971+ x and y must be 1-D sequences, and it is assumed, but not checked,
2972+ that x is uniformly increasing.
2973+
2974+ Make a step plot. The args and keyword args to step are the same
2975+ as the args to plot. See help plot for more info.
2976+
2977+ Additional keyword args for step:
2978+
2979+ * where: can be 'pre', 'post' or 'mid'; if 'pre', the
2980+ interval from x[i] to x[i+1] has level y[i];
2981+ if 'post', that interval has level y[i+1];
2982+ and if 'mid', the jumps in y occur half-way
2983+ between the x-values. Default is 'pre'.
2984+ '''
2985+
2986+ where = kwargs .pop ('where' , 'pre' )
2987+
2988+ if not cbook .iterable (x ):
2989+ x = ma .array ([x ], dtype = npy .float_ )
2990+ if not cbook .iterable (y ):
2991+ y = ma .array ([y ], dtype = npy .float_ )
2992+
2993+ if where == 'pre' :
2994+ x2 = ma .zeros ((2 * len (x )- 1 ,), npy .float_ )
2995+ y2 = ma .zeros ((2 * len (y )- 1 ,), npy .float_ )
2996+
2997+ x2 [0 ::2 ], x2 [1 ::2 ] = x , x [:- 1 ]
2998+ y2 [0 ::2 ], y2 [1 :- 1 :2 ] = y , y [1 :]
2999+
3000+ elif where == 'post' :
3001+ x2 = ma .zeros ((2 * len (x )- 1 ,), npy .float_ )
3002+ y2 = ma .zeros ((2 * len (y )- 1 ,), npy .float_ )
3003+
3004+ x2 [::2 ], x2 [1 :- 1 :2 ] = x , x [1 :]
3005+ y2 [0 ::2 ], y2 [1 ::2 ] = y , y [:- 1 ]
3006+
3007+ elif where == 'mid' :
3008+ x2 = ma .zeros ((2 * len (x ),), npy .float_ )
3009+ y2 = ma .zeros ((2 * len (y ),), npy .float_ )
3010+
3011+ x2 [1 :- 1 :2 ] = 0.5 * (x [:- 1 ]+ x [1 :])
3012+ x2 [2 ::2 ] = 0.5 * (x [:- 1 ]+ x [1 :])
3013+ x2 [0 ], x2 [- 1 ] = x [0 ], x [- 1 ]
3014+
3015+ y2 [0 ::2 ], y2 [1 ::2 ] = y , y
3016+
3017+ return self .plot (x2 , y2 , * args , ** kwargs )
3018+
29673019
29683020 def bar (self , left , height , width = 0.8 , bottom = None ,
29693021 color = None , edgecolor = None , linewidth = None ,
0 commit comments