Results 1 to 7 of 7

Thread: qwt plot

  1. #1
    Join Date
    Feb 2011
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question qwt plot

    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)

  2. #2
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qwt plot

    if i understand you right. i think you miss calling QwtPlot::replot();

    or better yet show us some sample code

  3. #3
    Join Date
    Feb 2011
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: qwt plot

    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");

  4. #4
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qwt plot

    use CODE-Tags, please!

    you set cosinus-data after calling replot().

  5. #5
    Join Date
    Feb 2011
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: qwt plot

    thank you, till not working.

  6. #6
    Join Date
    May 2011
    Posts
    39
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qwt plot

    can you please mail me the pro file and all those necessary...
    suraj@robotics.org,np

  7. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qwt plot

    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:

    Qt Code:
    1. QwtPlot * plot = new QwtPlot;
    2.  
    3. QwtPlotCurve * curve1 = new QwtPlotCurve;
    4. // ... fill curve 1 with data
    5.  
    6. curve1->attach( plot );
    7.  
    8. QwtPlotCurve * curve2 = new QwtPlotCurve;
    9. // ... fill curve 2 with data
    10.  
    11. curve2->attach( plot );
    12.  
    13. QwtPlotCurve * curve3 = new QwtPlotCurve;
    14. // ... fill curve 3 with data
    15.  
    16. curve3->attach( plot );
    To copy to clipboard, switch view to plain text mode 

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

Similar Threads

  1. Put plot axis out of the plot
    By KosyakOFF in forum Qwt
    Replies: 7
    Last Post: 21st June 2013, 13:36
  2. Plot does not refresh
    By Mat12345 in forum Qwt
    Replies: 3
    Last Post: 21st October 2009, 22:45
  3. Cpu Plot walkthrough
    By maxpayne in forum Qwt
    Replies: 1
    Last Post: 13th October 2008, 11:16
  4. Plot Picker x=0
    By sun in forum Qwt
    Replies: 2
    Last Post: 7th October 2008, 07:43
  5. Replies: 7
    Last Post: 22nd September 2008, 22:05

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.