[cairo] Scatter plot optimization?

Andrej Prsa andrej.prsa at guest.arnes.si
Thu Mar 4 08:41:14 PST 2010


Dear Cairists,

I have a gtk drawing area to which I am drawing with cairo. The plot
consists of axes, axis labels, and scattered data -- 10,000+ data
points. Since I didn't find a good way how to do scatter plots with
different symbols, I am drawing symbols with cairo primitives, i.e.

	cairo_arc (data->canvas, x, y, 2.0, 0, 2*M_PI);

or:

	cairo_move_to (data->canvas, x-2, y-2);
	cairo_line_to (data->canvas, x+2, y+2);
	cairo_move_to (data->canvas, x+2, y-2);
	cairo_line_to (data->canvas, x-2, y+2);

followed by:

	cairo_stroke (data->canvas);

This results in a noticeable lag (from 0.5 to 5+ seconds for abundant
data points) to plot the data to the drawing area. I realize this must
be highly non-optimal and I would kindly ask for advice on how to do
this better. Since the example is more or less trivial, I didn't think
that including a trace would be crucial; please correct me if I'm wrong!

Thanks,
Andrej


More information about the cairo mailing list