 # How to create a square wave plot

Hi,

what’s the easiest method of creating a square wave plot?

Let’s say I have a data stream of bits that have values of “1” or “-1”.

The plot function wants to draw a diagonal line between those points but I need to have a horizontal line. So to get a “square wave” I must insert additional points to the series when the values change.

I wonder if there an easy way of doing this?

Hi,

···

On Tue, 02 Aug 2011 08:43:47 +0000, Freedom Fighter wrote:

Hi,

what's the easiest method of creating a square wave plot?
Let's say I have a data stream of bits that have values of "1" or
"-1".
The plot function wants to draw a diagonal line between those points
but I need to have a horizontal line. So to get a "square wave" I must
insert additional points to the series when the values change.
I wonder if there an easy way of doing this?

You can use the "step" function, which does exactly this and has arguments for setting where the step is made, etc.

Regards,

Sebastian