## Re: [Matplotlib-users] Hold value till the next point

 Re: [Matplotlib-users] Hold value till the next point From: N. Volbers - 2005-07-27 18:14:55 ```Hello Rameshwari! Vedpathak, Rameshwari IN BLR SISL schrieb: > Hello, > > The signals in matplotlib functionality are plotted by joining 2 points. > So if the signal values are say > y-axis: 0,1,2,3,4… > X-axis (time): 0, 10, 20, 30, 40…. > > then it draws a line which joins these points and the signal that we > see is a straight line ramping in upward direction. > > But I want to draw the signal such that it should hold the signal > value till the next point so that the signal now seen is like a step > ramp signal. > > So for the above example till time = 10 the value should be 0 and > again from time = 10 to time =20 value should be 1. > > Does anyone have an idea how to draw such signals with matplotlib > functionality) > Matplotlib indeed has this functionality :-). Try: x = [0,10,20,30,40] y = [0,1,2,3,4] plot( x, y, linestyle="steps" ) Best regards, Niklas. ```

 [Matplotlib-users] Hold value till the next point From: Vedpathak, Rameshwari IN BLR SISL - 2005-07-27 12:41:56 Attachments: Message as HTML ```Hello, The signals in matplotlib functionality are plotted by joining 2 points. So if the signal values are say=20 y-axis: 0,1,2,3,4... X-axis (time): 0, 10, 20, 30, 40.... then it draws a line which joins these points and the signal that we see is a straight line ramping in upward direction. But I want to draw the signal such that it should hold the signal value till the next point so that the signal now seen is like a step ramp signal. So for the above example till time =3D 10 the value should be 0 and = again from time =3D 10 to time =3D20 value should be 1. Does anyone have an idea how to draw such signals with matplotlib functionality Best Regards, Rameshwari ```
 Re: [Matplotlib-users] Hold value till the next point From: Alan G Isaac - 2005-07-27 16:05:24 ```On Wed, 27 Jul 2005, Rameshwari IN SISL Vedpathak apparently wrote:=20 > y-axis: 0,1,2,3,4... X-axis (time): 0, 10, 20, 30,=20 > 40....=20 > So for the above example till time =3D 10 the value should=20 > be 0 and again from time =3D 10 to time =3D20 value should be=20 > 1.=20 > Does anyone have an idea how to draw such signals with matplotlib=20 > functionality=20 Someone else may tell you this functionality is already=20 built into Matplotlib. If not, you can just repeat values. I do not know what the best way to do this is, but the following should work. (You'll probably want to fiddle with=20 the axes.) Alan Isaac def step_pts(x,y): =09pts=3Dzip(x,y) =09inter =3D zip(x[1:],y[:-1]) =09z =3D zip(*[j for i in map(None,pts,inter) for j in i][:-1]) =09return z[0],z[1] x =3D [0.,10.,20.,30.] y =3D [1.,2.,3.,4.] from pylab import * plot(*step_pts(x,y)) show() ```
 Re: [Matplotlib-users] Hold value till the next point From: N. Volbers - 2005-07-27 18:14:55 ```Hello Rameshwari! Vedpathak, Rameshwari IN BLR SISL schrieb: > Hello, > > The signals in matplotlib functionality are plotted by joining 2 points. > So if the signal values are say > y-axis: 0,1,2,3,4… > X-axis (time): 0, 10, 20, 30, 40…. > > then it draws a line which joins these points and the signal that we > see is a straight line ramping in upward direction. > > But I want to draw the signal such that it should hold the signal > value till the next point so that the signal now seen is like a step > ramp signal. > > So for the above example till time = 10 the value should be 0 and > again from time = 10 to time =20 value should be 1. > > Does anyone have an idea how to draw such signals with matplotlib > functionality) > Matplotlib indeed has this functionality :-). Try: x = [0,10,20,30,40] y = [0,1,2,3,4] plot( x, y, linestyle="steps" ) Best regards, Niklas. ```