1 Attachment(s)
Extra line appears on plot with startTimer()
Hallo,
I would like to read & plot data, say every 1 sec (i.e new curve should replace the old one). I have plotted the graph (see attached figure) okay but when I use the timer an extra line (average?) appears on graph. At the moment it's reading the same data every 1 sec but later it will be replaced by new set of data.
Any idea why the extra line appears, and how to remove it?
Thank you.
Attachment 9366
Code:
{
….
…
(void) startTimer(1000);// 1 sec
//populate(); //this works fine
connect( legend,
SIGNAL( checked
( const QVariant &,
bool,
int ) ),
SLOT( legendChecked
( const QVariant &,
bool ) ) );
}
void Plot::populate()
{
….Read data from a file…..
for ( int c = 0; c < 3; c++ )
data[c].curve->setRawSamples(&timeData.front(), &yData[c].front(), timeData.size() );
}
{
populate(); //Getting data for plotting
replot(); // to refresh plot
}
Re: Extra line appears on plot with startTimer()
Because there is a wrong data point(s) at the end of your data - or the size is wrong and the last point is random ( often 0, 0 ).
Uwe
Re: Extra line appears on plot with startTimer()
Quote:
Originally Posted by
Uwe
Because there is a wrong data point(s) at the end of your data - or the size is wrong and the last point is random ( often 0, 0 ).
Uwe
Thanks a lot Uwe. You are right. The vector size was growing each time the data file is read. Once I clear the vectors the trace is gone.