PDA

View Full Version : qwt plot



kamalasan
3rd February 2011, 17:50
iam trying to plot two cureves from two different files.but it displaying only one.
but individually it is displaying both and from single file also showing both.
please give me suggession to plot both curves from two different files in qwt(windows)

baray98
3rd February 2011, 19:39
if i understand you right. i think you miss calling QwtPlot::replot();

or better yet show us some sample code

kamalasan
4th February 2011, 05:40
here iam attching my cod
void Analysee::change()
{
int j=0;
j=ui->comboBox->currentIndex();
if(j==1)
{
ui->qwtPlot->clear();
ui->qwtPlot_2->clear();
ui->qwtPlot_3->clear();
QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
#if QT_VERSION >= 0x040000
cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
cSin->setPen(QPen(Qt::red));
cSin->attach(ui->qwtPlot);
QwtPlotCurve *cSin_2 = new QwtPlotCurve("y = sin(x)");
#if QT_VERSION >= 0x040000
cSin_2->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
cSin_2->setPen(QPen(Qt::red));
cSin_2->attach(ui->qwtPlot_2);
QwtPlotCurve *cSin_3 = new QwtPlotCurve("y = sin(x)");
#if QT_VERSION >= 0x040000
cSin_3->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
cSin_3->setPen(QPen(Qt::red));
cSin_3->attach(ui->qwtPlot_3);

QwtPlotCurve *cCos = new QwtPlotCurve("y = sin(x)");
#if QT_VERSION >= 0x040000
cCos->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
cCos->setPen(QPen(Qt::green));
cCos->attach(ui->qwtPlot);
QwtPlotCurve *cCos_2 = new QwtPlotCurve("y = sin(x)");
#if QT_VERSION >= 0x040000
cCos_2->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
cCos_2->setPen(QPen(Qt::green));
cCos_2->attach(ui->qwtPlot_2);
QwtPlotCurve *cCos_3 = new QwtPlotCurve("y = sin(x)");
#if QT_VERSION >= 0x040000
cCos_3->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
cCos_3->setPen(QPen(Qt::green));
cCos_3->attach(ui->qwtPlot_3);

QFile inputFile("input_m.dat");
if(inputFile.open(QIODevice::ReadOnly|QIODevice::T ext))
{
coastX.clear();
coastY.clear();
coastV.clear();
coastA.clear();
coastB.clear();
coastC.clear();
coastD.clear();
// coastZ.clear();
QTextStream in(&inputFile);
do
{
in >> tempDouble1 >> tempDouble2>> tempDouble3>> tempDouble4>> tempDouble5>> tempDouble6>> tempDouble7;
coastX << tempDouble1;
coastY << tempDouble5;
coastA <<tempDouble6;
coastC <<tempDouble7;
} while(!in.atEnd());
}
cSin->setData(coastY,coastX);
cSin_2->setData(coastA,coastX);
cSin_3->setData(coastC,coastX);


QFile inputFil("OUTPUT.dat");
if(inputFil.open(QIODevice::ReadOnly|QIODevice::Te xt))
{
coastX.clear();
coastY.clear();
coastV.clear();
coastZ.clear();
QTextStream in(&inputFil);
do
{
in >> tempDouble1>> tempDouble2>> tempDouble3>> tempDouble4;//>> tempDouble5>> tempDouble6>> tempDouble7>> tempDouble8>> tempDouble9>> tempDouble10>> tempDouble11>> tempDouble12>> tempDouble13;

coastX << tempDouble1;
coastY << tempDouble2;
coastA << tempDouble3;
coastC << tempDouble4;
} while(!in.atEnd());
}
ui->qwtPlot->replot();
cCos->setData(coastX,coastY);
ui->qwtPlot->show();
ui->qwtPlot_2->replot();
cCos_2->setData(coastX,coastA);
ui->qwtPlot_2->show();
ui->qwtPlot_3->replot();
cCos_3->setData(coastX,coastC);
ui->qwtPlot_3->show();
ui->qwtPlot->setTitle("Roll");
ui->qwtPlot_2->setTitle("Pitch");
ui->qwtPlot_3->setTitle("Heading");
ui->qwtPlot->setAxisTitle(QwtPlot::yLeft, "deg");
ui->qwtPlot_2->setAxisTitle(QwtPlot::yLeft, "deg");
ui->qwtPlot_3->setAxisTitle(QwtPlot::yLeft, "deg");
ui->qwtPlot->setAxisTitle(QwtPlot::xBottom, "sec");
ui->qwtPlot_2->setAxisTitle(QwtPlot::xBottom, "sec");
ui->qwtPlot_3->setAxisTitle(QwtPlot::xBottom, "sec");

FelixB
4th February 2011, 10:16
use CODE-Tags, please!

you set cosinus-data after calling replot().

kamalasan
5th February 2011, 10:38
thank you, till not working.

robotics
15th June 2011, 19:26
can you please mail me the pro file and all those necessary...
suraj@robotics.org,np

d_stranz
18th June 2011, 16:24
You are creating 3 QwtPlot instances. Are you also creating 3 different views to put them in, or are you trying to display everything in 1 view? If you aren't creating 3 views, then probably all of your QwtPlots are on top of each other, and only the top one gets displayed.

Do something like this instead:



QwtPlot * plot = new QwtPlot;

QwtPlotCurve * curve1 = new QwtPlotCurve;
// ... fill curve 1 with data

curve1->attach( plot );

QwtPlotCurve * curve2 = new QwtPlotCurve;
// ... fill curve 2 with data

curve2->attach( plot );

QwtPlotCurve * curve3 = new QwtPlotCurve;
// ... fill curve 3 with data

curve3->attach( plot );



All three curves should now be displayed on the same plot.