11

I have a huge array of 2D points (about 3 millions of pairs), which I need to render with reasonable speed in a Qt-based application.

I've tried using QGraphicsScene, but its very slow even on 400000 primitives, so I was looking into the qwt library instead.

It has a scatter plot example screenshot on its sourceforge page, which looks like exactly what I need, but I cannot find neither any kind of actual code that can be used for this data, nor an according API in qwt docs - it mentions only different types of curves.

So it would be good to get some pointers for scatter plot examples and some advice on its performance. Suggestions for other c++ qt-compatible plotting libraries which can cope with this amount of data are also welcome.

codeling
  • 11,056
  • 4
  • 42
  • 71
Daniel Kluev
  • 11,025
  • 2
  • 36
  • 36

4 Answers4

16

Scatter plot is contained in the "realtime" example: what you want is the IncrementalPlot class. I'd also suggest that drawing all the 3 million points isn't reasonable, since modern screens have only about 2 million pixels :) Thus it seems better to simplify the plot beforehand by merging the adjacent points into one with a threshold dependent on the zoom factor.

vines
  • 5,160
  • 1
  • 27
  • 49
  • Haha, 3 million points on 2 million pixels is ... a density plot ;-) – rubenvb Jul 07 '11 at 14:47
  • @rubenvb: though we still can triplicate the resolution by counting RGB components as separate dots! :D – vines Jul 07 '11 at 15:02
  • Approach used in IncrementalPlot turned out to be fast enough, thanks. Wasn't very obvious that "scatter plot" is based on PlotCurve without line. – Daniel Kluev Jul 15 '11 at 08:07
6

As viens pointed out, generating scatter plots with 3 million points is probably not a good idea.

I have achieved good performance generating 3D scatter plots with 30.000 points using OpenGL. OpenGL is fast and integrates well with Qt. However, it is a low level API that forces you to do a lot of tedious coding.

VTK may be another option.

Johan Råde
  • 20,480
  • 21
  • 73
  • 110
3

MathGL is free (GPL) cross-platform plotting library. It was written in C++ and have Qt widget. Also it is rather fast, but 3 millions points ... it take about 30 seconds to plot in my laptop.

abalakin
  • 825
  • 7
  • 6
2

You'd suggest using OpenGL as @vines said, and in particular exploiting or display lists glGenList or vertex buffers. Some million points as primitives vertices shouldn't be that difficult.

linello
  • 8,451
  • 18
  • 63
  • 109