PDA

View Full Version : How to plot a huuuuge number of data points?



CotWoAU
15th June 2011, 20:46
My project loads a data file of anywhere between 100 and 100,000 data points, and then plots them on a graph.

Currently I'm trying to figure out what's the most efficient way to do this? Plotting 100,000 data points on a graph would take a long long time (I think).

Currently, I create two const double arrays and curve->setSamples(x, y, n), but I don't know how well this works for large arrays. Is there some function or method by which I can plot a fraction of the data points (say one in ten?), and then still be able to see all the data points when I zoom in?

Thanks for any help

FelixB
16th June 2011, 07:40
you can set a CurveFitter to reduce the number of points. I don't know how to use it exactly because I never needed them, but I'm sure reading the documentation will help you ;)

CotWoAU
17th June 2011, 15:26
Thanks! I found the QwtCurveFitter class, and am currently trying to use QwtWeedingCurveFitter.

I'm kinda new to Qt, and I can't quite get how to construct QPolygonF to hold my data. Could someone show me an example of how to construct one?

I have two arrays full of double's atm.

Thanks!!

FelixB
17th June 2011, 15:48
as far as I understand CurveFitter, you don't have to do anything by yourself. just pass the fitter to your curve and activate attribut "fitted". that should be all...

CotWoAU
17th June 2011, 16:41
Thanks for the help!! Finally got it to work with a few sample points!! Now I'll give it a go with my actual data.


In case anyone's interested in how to use the QwtWeedingCurveFitter:



QwtWeedingCurveFitter *velocityCurve = new QwtWeedingCurveFitter();
velocityCurve->setTolerance(1.0);

//QwtSplineCurveFitter *velocityCurve = new QwtSplineCurveFitter ();

QwtPlotCurve *curve = new QwtPlotCurve();
curve->setStyle(QwtPlotCurve::Lines);
curve->setCurveFitter(velocityCurve);
curve->setCurveAttribute(QwtPlotCurve::Fitted, true);
const double x[] = {0, 1, 2, 4, 5, 8, 10, 13, 14, 19};
const double y[] = {17, 16.5, 8, 3, 5, 7.5, 9, 10, 12, 14};
curve->setSamples(x, y, 10);
curve->attach(leftGraph);

leftGraph->replot();


Edit: I shoulda prolly say that I 'think' it's working. Obviously, without a large number of datapoints to test it on, I can't relaly tell.

Uwe
17th June 2011, 17:53
Using QwtWeedingCurveFitter this way doesn't make much sense as the algorithm for reducing the points takes much longer than painting all points.

Instead I recommend to check the refreshtest example first to see, what type of performance you can expect for 100000 points on your system. If this is not fast enough the common way to improve performance is to implement different levels of detail depending on the scale ranges. Here QwtWeedingCurveFitter is of use for creating different data sets.

Check the archive of this forum,

Uwe