Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear QwtPlot curves before replotting?

Tags:

c++

qt

qwt

In the earlier versions of Qwt we add QwtPlot::clear() but now, I can't find it.

Any ideas? I have a real time plot, so when replotting, the info before xmin is not really important and with time it crashes as the replot is replotting all the information before xmin.

like image 487
SamuelNLP Avatar asked Mar 13 '13 12:03

SamuelNLP


People also ask

How to clear the plot of a qwtplot?

one of the way to clear plot is to set your data points to empty: for example: (m_vctTime,m_vctValue -vector) (curve=new QwtPlotCurve ()) (plot=new QwtPlot (parent)) Thanks for contributing an answer to Stack Overflow!

How does qwtplotcurve work?

QwtPlotCurve tries to find a color representing the curve and paints a rectangle with it. If the style () is not QwtPlotCurve::NoCurve a line is painted with the curve pen (). If the curve has a valid symbol it is painted.

What is baseline in Qwt_plot_curve?

Definition at line 145 of file qwt_plot_curve.cpp. Set the value of the baseline. The baseline is needed for filling the curve with a brush or the Sticks drawing style. The interpretation of the baseline depends on the orientation ().

How does the fill algorithm work in QW plot?

The fill algorithm simply connects the first and the last curve point to the baseline. So the curve data has to be sorted (ascending or descending). Definition at line 348 of file qwt_plot_curve.cpp.


2 Answers

The method Qwtplot::clear() has been deprecated. Use QwtPlotDict::detachItems instead.

void QwtPlotDict::detachItems(int rtti = QwtPlotItem::Rtti_PlotItem, 
                              bool autoDelete = true 
                             )

Parameters:

rtti: In case of QwtPlotItem::Rtti_PlotItem detach all items otherwise only those items of the type rtti. autoDelete: If true, delete all detached items

like image 127
bruno Avatar answered Oct 07 '22 01:10

bruno


one of the way to clear plot is to set your data points to empty: for example: (m_vctTime,m_vctValue -vector) (curve=new QwtPlotCurve()) (plot=new QwtPlot(parent))

m_vctTime.clear();
m_vctValue.clear();
curve->setSamples(m_vctTime,m_vctValue);
plot->replot();    

that clears your plot

like image 39
AlexBee Avatar answered Oct 07 '22 01:10

AlexBee