How to draw square wave using ZedGraph?
I'm thinking about something like this:
My formula is:
y = amplitude, if sin(x) >=0
y = -amplitude, if sin(x) < 0
In theory it should give a square wave, but gives me:
How to draw square wave using ZedGraph?
I'm thinking about something like this:
My formula is:
y = amplitude, if sin(x) >=0
y = -amplitude, if sin(x) < 0
In theory it should give a square wave, but gives me:
It looks like it's stepping at discrete values along the X axis (which is really almost unavoidable), and drawing a steep (but still visibly non-vertical) line from the last point at which it sampled a positive sin(x), through sin(x)=0 to the next point at which it sample a negative sin(x).
The obvious cure is to tell it to sample the function at smaller intervals -- specifically, small enough so the transition from +1 to -1 (or vice versa) happens in less than the width of a pixel as you'll end up displaying it.
You should change the step type of your curve. Use:
line.Line.StepType = StepType.ForwardStep;
of course line
is your LineItem
object