PDA

View Full Version : how to create a colorful scatter plot ?



Nicho
17th July 2013, 13:41
Hi
Uwe ,
could you give me some advice about how to create a colorful scatter plot ?
the colors represent the third dimension .
I have made a subclass from QwtPlotCurve,and implemented draw().
But I wonder if there is another way based on qwt6.1 to make my application achieve a better performance .
Thanks.

Nicho

jesse_mark
17th July 2013, 17:56
have alook at QwtPlotSpectroCurve, maybe will do wat you want.

Nicho
18th July 2013, 04:05
have alook at QwtPlotSpectroCurve, maybe will do wat you want.

thank you , Jesse
i have taken a look at that class .
it seems like what i have done in my subclass .
and in my way,the performance comes down at the amount of tens of thousand of points or even more .

Nicho

Uwe
18th July 2013, 07:16
The scatterplot example shows a very fast implementation, that uses a couple of tricks, that are not possible for all types of scatter plots.

a) Points are rendered to a QImage by copying a RGB value to memory ( no QPainter involved )
b) Because of a) it is possible to render multithreaded

a) is only possible because the scatter plot example uses a 1 pixel dot for each point. For any other type of symbol you would need some render code that sets the pixels ( like QPainter does ), what will slow down the operation. When using a non opaque pen you would also have to manipulate the alpha value, when several points are on the same position.

When having different colors b) might be a problem, because the order of how points are rendered will be arbitrary.

Nevertheless mapping a z value to a RGB value will slow down the operation. But this mapping doesn't necessarily be done inside of the render loop repeated for every replot.

One comment on your code: when you really have a significant performance issue with about ~10000 points there must be something wrong. Do you notice the same bad performance when using QwtPlotSpectroCurve ( try an antialiased pen with a width of 1 ) ?

Uwe