Results 1 to 14 of 14

Thread: Plot the graph for real time data

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2007
    Posts
    55
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Plot the graph for real time data

    sorry, but I do not undestand what you are meaning.
    In my example, the plot is actualized in real time, and plotted continuously. The question is just wether your hardware is fast enough to do that.
    You might define what you mean with real time.
    The strong interpretation is that you are able to display the data one by one as they are available, continuously without any data loss.
    A weaker interpretation of real time ist that you are displaying the new data in blocks of several data, but still without data loss.

  2. #2
    Join Date
    Jul 2013
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Plot the graph for real time data

    sorry for my explanation. for the question
    The question is just wether your hardware is fast enough to do that.
    It is able to do as fast as much.

    for( i=0; i<n; i++ )
    {
    QString result=read_data.at(i);
    result.remove(0,10);
    qDebug("%s",result.toLatin1().data());
    y[i]=result.toLatin1().toFloat();
    points << QPointF( i, y[i] );
    // check wether curve is updated, if not do it here
    plot->replot;
    plot->show;
    }
    It is the part of your code. In this you write the code

    plot->replot;
    plot->show;

    in for loop.
    My question is, loop will execute for every i value till it reaches the count.

    the code in the loop will excute for every "i" value so plot->show is also excute for every value.

    means it will open the plot window for every i value.

    I have tested your code, it will displaying so many no of windows

    how to modify that code to plot the graph continuously.

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Plot the graph for real time data

    2 considerations, when implementing a realtime plot - especially when you expect to have many, many samples:


    • always decouple sample and refresh rate
      decoupling the rates means, that you only add new samples to a buffer without repainting. The curve update depends on a timer that runs periodically triggering a replot only when something has changed in the last cycle.
    • consider to use incremental painting
      incremental painting means, that you design your plot in a way, that it doesn't change for new samples - beside of drawing a couple of new lines ( the oscilloscope example is designed this way ). But this is only possible when you don't have to change the scales.


    Nore that the oscilloscope example runs with heavy data and high refresh rates with low CPU usage - even on a device like the PI !

    Uwe

  4. The following user says thank you to Uwe for this useful post:

    Momergil (27th June 2014)

  5. #4
    Join Date
    Jul 2013
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Plot the graph for real time data

    consider to use incremental painting
    incremental painting means, that you design your plot in a way, that it doesn't change for new samples - beside of drawing a couple of new lines ( the oscilloscope example is designed this way ). But this is only possible when you don't have to change the scales.
    Sorry I am a bit confused,

    UWE said that
    "incremental painting means, that you design your plot in a way, that it doesn't change for new samples"
    that it doesn't change for new samples means every time It shows only previous samples only?
    can you explain me

  6. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Plot the graph for real time data

    Incremental in this context means that only the new parts of a curve are painted on top of the existing plot - without repainting from scratch.

    Uwe

  7. #6
    Join Date
    Jul 2013
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Plot the graph for real time data

    thank you for reply,

    in that Oscilloscope example there are so many .pri files were added. these files are needed or not???\

  8. #7
    Join Date
    Jul 2013
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Plot the graph for real time data

    UWE said that

    the new parts of a curve are painted on top of the existing plot,,

    means only top values are plotted?

  9. #8
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Plot the graph for real time data

    With QwtPlotDirectPainter you can draw any part of a curve on top of an existing plot - without repainting the plot. It is up to the application code which part you want to draw - but usually these are points, that are not painted already ( = new ).

    Uwe

  10. #9
    Join Date
    Jul 2013
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Plot the graph for real time data

    I want each and every value from starting to ending. how it is possible? can you explain me

  11. #10
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Plot the graph for real time data

    QwtPlot::replot().

    Uwe

  12. #11
    Join Date
    Jul 2013
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Plot the graph for real time data

    I want to clarify one doubt,

    Can I use oscilloscope example as reference to my requirement?

Similar Threads

  1. Replies: 3
    Last Post: 12th April 2013, 06:18
  2. Replies: 2
    Last Post: 5th April 2013, 04:58
  3. How to plot real time x/y graph in Qtopia
    By desperado_43 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 18th May 2012, 08:00
  4. Replies: 2
    Last Post: 24th June 2011, 05:31
  5. real time graph plot
    By robotics in forum Qt Programming
    Replies: 5
    Last Post: 24th May 2011, 05:04

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
  •  
Qt is a trademark of The Qt Company.