// Generate data
QVector<QPointF> points
{ QPointF(0,
25),
QPointF(10,
12),
QPointF(20,
20),
QPointF(30,
31),
QPointF(40,
20),
QPointF(50,
15) };
QVector<QwtIntervalSample> intervalData{ QwtIntervalSample(0, 22, 28), QwtIntervalSample(10, 9, 15), QwtIntervalSample(20, 18, 22),
QwtIntervalSample(30, 29, 33), QwtIntervalSample(40, 15, 25), QwtIntervalSample(50, 9, 21) };
// Create curve
curve->setSamples(points);
curve
->setPen
(QPen(Qt
::darkGreen));
curve->attach(m_plot);
// Create interval curve
auto errorCurve = new QwtPlotIntervalCurve();
errorCurve->setSamples(intervalData);
errorCurve->setStyle(QwtPlotIntervalCurve::NoCurve);
QwtIntervalSymbol* errorBar = new QwtIntervalSymbol(QwtIntervalSymbol::Bar);
errorBar->setWidth(8);
errorBar
->setPen
(QPen(Qt
::black));
errorCurve->setSymbol(errorBar);
errorCurve
->setRenderHint
(QwtPlotItem::RenderAntialiased,
false);
errorCurve->attach(m_plot);
// Apply auto scale
m_plot
->setAxisAutoScale
(QwtPlot::xBottom,
true);
m_plot
->setAxisAutoScale
(QwtPlot::yLeft,
true);
m_plot->replot();
// Generate data
QVector<QPointF> points{ QPointF(0, 25), QPointF(10, 12), QPointF(20, 20), QPointF(30, 31), QPointF(40, 20), QPointF(50, 15) };
QVector<QwtIntervalSample> intervalData{ QwtIntervalSample(0, 22, 28), QwtIntervalSample(10, 9, 15), QwtIntervalSample(20, 18, 22),
QwtIntervalSample(30, 29, 33), QwtIntervalSample(40, 15, 25), QwtIntervalSample(50, 9, 21) };
// Create curve
auto curve = new QwtPlotCurve();
curve->setSamples(points);
curve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse, QBrush(Qt::darkGreen), QPen(Qt::green), QSize(10, 10)));
curve->setPen(QPen(Qt::darkGreen));
curve->attach(m_plot);
// Create interval curve
auto errorCurve = new QwtPlotIntervalCurve();
errorCurve->setSamples(intervalData);
errorCurve->setStyle(QwtPlotIntervalCurve::NoCurve);
QwtIntervalSymbol* errorBar = new QwtIntervalSymbol(QwtIntervalSymbol::Bar);
errorBar->setWidth(8);
errorBar->setPen(QPen(Qt::black));
errorCurve->setSymbol(errorBar);
errorCurve->setRenderHint(QwtPlotItem::RenderAntialiased, false);
errorCurve->attach(m_plot);
// Apply auto scale
m_plot->setAxisAutoScale(QwtPlot::xBottom, true);
m_plot->setAxisAutoScale(QwtPlot::yLeft, true);
m_plot->replot();
To copy to clipboard, switch view to plain text mode
Bookmarks