Hi,
I would like to plot multiple curves on one qwtplot object.
QwtPointSeriesData* myData = new QwtPointSeriesData;
QVector<QPointF>* samples = new QVector<QPointF>;
samples
->push_back
(QPointF(time
->at
(0), samplesPerUser
[0]));
//creating histogram
for (int i=1; i<30; i++) {
samples
->push_back
(QPointF((time
->at
(i
) + time
->at
(i
+1)) / 2, samplesPerUser
[i
]));
samples
->push_back
(QPointF((time
->at
(i
) + time
->at
(i
+1)) / 2, samplesPerUser
[i
+1]));
}
samples
->push_back
(QPointF(time
->at
(30), samplesPerUser
[30]));
myData->setSamples(*samples);
mycurve->setData(myData);
mycurve->attach(plot);
QwtPointSeriesData* myData2 = new QwtPointSeriesData;
QVector<QPointF>* samples2 = new QVector<QPointF>;
samples
->push_back
(QPointF(time
->at
(0), samplesPerUser2
[0]));
//creating histogram
for (int i=1; i<30; i++) {
samples2
->push_back
(QPointF((time
->at
(i
) + time
->at
(i
+1)) / 2, samplesPerUser2
[i
]));
samples2
->push_back
(QPointF((time
->at
(i
) + time
->at
(i
+1)) / 2, samplesPerUser2
[i
+1]));
}
samples
->push_back
(QPointF(time
->at
(30), samplesPerUser2
[30]));
myData->setSamples(*samples2);
mycurve->setData(myData2);
//making the second curve red
mycurve2
->setPen
(QPen(Qt
::red));
mycurve2->attach(plot);
QwtPlotCurve* mycurve = new QwtPlotCurve("curve1");
QwtPlotCurve* mycurve2 = new QwtPlotCurve("curve2");
QwtPointSeriesData* myData = new QwtPointSeriesData;
QVector<QPointF>* samples = new QVector<QPointF>;
samples->push_back(QPointF(time->at(0), samplesPerUser[0]));
//creating histogram
for (int i=1; i<30; i++) {
samples->push_back(QPointF((time->at(i) + time->at(i+1)) / 2, samplesPerUser[i]));
samples->push_back(QPointF((time->at(i) + time->at(i+1)) / 2, samplesPerUser[i+1]));
}
samples->push_back(QPointF(time->at(30), samplesPerUser[30]));
myData->setSamples(*samples);
mycurve->setData(myData);
mycurve->attach(plot);
QwtPointSeriesData* myData2 = new QwtPointSeriesData;
QVector<QPointF>* samples2 = new QVector<QPointF>;
samples->push_back(QPointF(time->at(0), samplesPerUser2[0]));
//creating histogram
for (int i=1; i<30; i++) {
samples2->push_back(QPointF((time->at(i) + time->at(i+1)) / 2, samplesPerUser2[i]));
samples2->push_back(QPointF((time->at(i) + time->at(i+1)) / 2, samplesPerUser2[i+1]));
}
samples->push_back(QPointF(time->at(30), samplesPerUser2[30]));
myData->setSamples(*samples2);
mycurve->setData(myData2);
//making the second curve red
mycurve2->setPen(QPen(Qt::red));
mycurve2->attach(plot);
To copy to clipboard, switch view to plain text mode
The problem is that I can see only the second curve, not the first one. I'm not sure whether creating 2 QwtPlotCurve object and attaching them to the plot is a right approach.
Bookmarks