I have a large collection of 2D coordinates (i.e., easily in the order of 100k to 200k x,y pairs) that I would like to visualize as a scatter plot. For the application that this is intended for, having so many points makes sense and I can't/won't reduce the number for different reasons. To plot this in Java, I use JFreeChart. I have played around with ChartFactory.createScatterPlot()
and 50k randomly generated points, and while this gives the greatest amount of flexibility to set the appearance (point size/color/shape), it is slow for displaying many points. That means, it takes some time to appear and zooming is also delayed/not smooth. However, once only few points are actually visible, i.e., deeply zoomed in, the visualization is nicely responsive.
On the contrary, FastScatterPlot()
allows to easily draw 500k randomly generated 2D points but the appearance is not really nice as I managed only to set the color so far (using, e.g., setPaint(Color.BLUE)
) but not the shape or the size. The size is a problem in particular as the individual points are really small.
How can I change the point size or shape in FastScatterPlot
?
And related to this, is there a way to make the chart returned by ChartFactory.createScatterPlot()
more responsive?
My data is fixed and the rendering must principally not necessarily change during runtime hence if there are ways to disconnect any listeners or such to improve performance, this would also be an option.
Thanks in advance.
For speed, you might try the alternate FastScatterPlot
calculation suggested in the render()
method's source comments; profile to compare. For size, you can change the rendered size in the same method; the following would quadruple the size of each point.
g2.fillRect(transX, transY, 2, 2);