Hi all,

I'm a newbie in QWT. I'm trying to plot a real time curve that runs from -6 to 6. I'm able to get the real time plot to work with the help of Timer(). But there is a strange line extending to my plot when the graph plot itself(see attached photo). Any kind soul can tell me where am i getting it wrong?

My code are as follows:

void TimeLinearity1:opulate1(int _time, QString wave1, QString wave2)
{
time = _time;
w1 = wave1;
w2 = wave2;

x1.resize(360),y1.resize(360);
if(w1 == "Square Wave")
{
for (int i=0; i<time; ++i)
{
x1[i] = (i/360.0-0.5)*30+0.01;
x1[i] *= 0.4;
if( x1[i]>=-2.5 && x1[i]<=2.5)
{
y1[i]=3;
}
else
{
y1[i]=0;
}

}
}
else if(w1 == "Triangle Wave")
{
for (int i=0; i<time; ++i)
{
x1[i] = (i/360.0-0.5)*30+0.01;
x1[i] *= 0.4;
if( x1[i]>=-2 && x1[i]<0)
{
y1[i]=(0.5*x1[i])+1;
}
else if(x1[i]>=0 && x1[i]<2)
{
y1[i]=1-(0.5*x1[i]);
}
else
{
y1[i]=0;
}
}
}

Wave->setPen( QColor(Qt::green) );
Wave->setSamples(x1, y1);
Wave->attach( this );
replot();
}

Thank you very much.

plot.jpg