[cairo] Scatter plot optimization?
Arjen Nienhuis
a.g.nienhuis at gmail.com
Thu Mar 4 09:40:35 PST 2010
See this discussion:
http://comments.gmane.org/gmane.comp.lib.cairo/18734
The trick is to do this one time:
cairo_clip(...)
cairo_push_group(...);
<draw symbol>
sym = cairo_pop_group(...);
And do this many times:
cairo_set_source(..., sym)
cairo_paint(...)
On Thu, Mar 4, 2010 at 5:41 PM, Andrej Prsa <andrej.prsa at guest.arnes.si> wrote:
> 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
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
More information about the cairo
mailing list