Results 1 to 3 of 3

Thread: How to plot the large real time data in qwtplot ?

  1. #1
    Join Date
    Dec 2017
    Qt products

    Default How to plot the large real time data in qwtplot ?


    I would like to plot the large amount of data in graph. data is near about 5 million.

    1. How can I plot that data efficiently on graph?
    I use below method to update the graph in real time.

    Qt Code:
    1. LargeDataPlot::LargeDataPlot() :d_paintedPoints(0)
    2. {
    3. d_directPainter = new QwtPlotDirectPainter();
    5. setAutoReplot(false);
    6. setCanvas(new Canvas());
    7. }
    16. LargeDataPlot::~LargeDataPlot()
    17. {
    18. d_directPainter->deleteLater();
    19. }
    25. void LargeDataPlot::updateCurve(QwtPlotCurve* d_curve)
    26. {
    27. auto curveData = d_curve->data();
    28. const int numPoints = curveData->size();
    30. if (numPoints > 0) {
    32. const bool doClip = !canvas()->testAttribute(Qt::WA_PaintOnScreen);
    33. if (doClip)
    34. {
    35. /*
    36. Depending on the platform setting a clip might be an important
    37. performance issue. F.e. for Qt Embedded this reduces the
    38. part of the backing store that has to be copied out - maybe
    39. to an unaccelerated frame buffer device.
    40. */
    41. const QwtScaleMap xMap = canvasMap(d_curve->xAxis());
    42. const QwtScaleMap yMap = canvasMap(d_curve->yAxis());
    44. QRegion clipRegion;
    46. const QSize symbolSize = d_curve->symbol()->size();
    47. QRect r(0, 0, symbolSize.width() + 2, symbolSize.height() + 2);
    49. const QPointF center =
    50. QwtScaleMap::transform(xMap, yMap, curveData->sample(numPoints - 1));
    51. r.moveCenter(center.toPoint());
    52. clipRegion += r;
    54. d_directPainter->setClipRegion(clipRegion);
    55. }
    57. d_directPainter->drawSeries(d_curve,
    58. numPoints - 1, numPoints - 1);
    59. }
    61. }
    To copy to clipboard, switch view to plain text mode 


    2. How can Line in between two data point in curve.

    I need to some functionality from qwtPlot, which is help to first identify the curve pen color and symbol.
    then I need to plot the line in between last point and second last point.

    3. How can I change the axis scale in real time?

    If i will call replot then plot is change the axis scale according to Data value.


    4. At few place I am using QwtPlot::replot() method of graph. such as zoom in, zoom out, reste the graph, and mouse wheel direction change.

    is it any alternative way instead of replot because of replot is very slow whenever large amount of data is available.


    5. if possible then I am planing to optimized the large amount of data, amd trying to make smooth curve.


    To implement max-min decimation, first determine the pixel width of the graph. Use the Plot Area:Size:Width property of the graph to find this. To reduce artifacts, you need at least two decimation intervals per pixel width, so multiply the graph pixel width by two to get the nominal number of intervals to divide the data into. Divide the data length by this number and round up to the nearest integer. This gives you the chunk size for decimation. For each chunk, find the maximum and minimum points and order them in the same order they occurred in the data set. Do not worry that the last chunk has less points than the rest. The problem is less than a pixel wide and cannot be seen on the computer screen. String all the max and min data together and plot. You will have four points per pixel width on the screen. This allows the single, pixel-wide spike to occur without bleeding over into adjacent pixels. The max/min decimation assures you always see the peaks of the data, giving you the solid band the high frequency sine wave should produce. This all occurs with much less data plotted to the graph, resulting in much higher speeds.

    is it any way to change the chunk size with respect to zoom in and zoom out.

    if it is Zoom out then i would like to increase the chunk size and if it is zoom in and i would like to decrease the chunk size.
    in general i would like to modify value inside QwtWeedingCurveFitter::setChunkSize().


    Any please help of or give me direction for archive functionality.
    Last edited by yashkumar; 12th December 2019 at 20:01.

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

    Default Re: How to plot the large real time data in qwtplot ?

    Please split your posting into single questions and try to find a solution for them on your own first. I try to help when someone gets stuck, but I'm not going to do your job.

    Regarding the min/max optimization. It is implemented in all branches >= 6.2 and can be activated by setting the QwtPlotCurve::FilterPointsAggressive ( fast algo can be done inside the update cycle ) flag.

    But even with having all optimizations enabled I don't recommend to pass all 5 million points to the plot and you should do some sort of preprocessing to reduce the number of points.
    Maybe overload QwtSeriesData<QPointF> and do some magic behind the scenes. F.e you can calculate different data sets according to the zoom level using QwtWeedingCurveFitter ( too slow to do it in the update cycle ! ).

    Showing real time data with a certain refresh rate is a different story. But in general you should always decouple the update rate from the sample rate - drawing each point as it arrives is no good idea. There is not much sense in having a higher refresh rate than let's say 10fps - a line plot is no movie, where the complete screen gets updated with each frame.

    In all branches >= 6.2 you will find a lot of spline interpolation algos implemented, while in 6.1 you only have the cubic spline algo, that is expensive and its implementation is broken. If it is only about making a curve smooth spline interpolation is a good option.


  3. #3
    Join Date
    Dec 2017
    Qt products

    Default Re: How to plot the large real time data in qwtplot ?

    Thank you for your direction. I am able to improve performance after direction from you. I do have one question regarding QwtPlotCurve::minXvalue(), QwtPlotCurve::minYvalue(), QwtPlotCurve::maxXvalue(), and QwtPlotCurve::maxYvalue() funcation.

    I set the filter-container (QVector) point to curve using setSamples.
    curve1->setSamples(new ListSeriesData(*[QwtPlot::xBottom], *[QwtPlot::yLeft]));

    - ListSeriesData classs is derived from QwtSeriesData<QPointF>;

    if i will append new data in real time then it is paint on graph correctly using drawSeries().

    Now whenever I will call to curve1->minXvalue(); or curve1->maxXvalue(); or curve1->maxYvalue(); or curve1->minYvalue(); then it is always return zero.

    what could be the reason? why is it always return zero? Am i missing to set any things?

    Added after 1 26 minutes:

    I got solution i was doing mistake in setting QRectF boundingRect() const; inside the ListSeriesData class.
    I was setting the QRectF rect inside the constructor of ListSeriesData class and read by boundingRect();
    Last edited by yashkumar; 31st December 2019 at 20:50.

Similar Threads

  1. Plot the graph for real time data
    By swinetha in forum Qwt
    Replies: 13
    Last Post: 1st August 2013, 05:56
  2. Replies: 3
    Last Post: 12th April 2013, 07:18
  3. Replies: 2
    Last Post: 5th April 2013, 05:58
  4. Replies: 1
    Last Post: 27th April 2011, 11:35
  5. Replies: 5
    Last Post: 19th November 2010, 03:25

Tags for this Thread


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.