diff --git a/include/plot.h b/include/plot.h index 19d2a21..dcb747a 100644 --- a/include/plot.h +++ b/include/plot.h @@ -42,7 +42,7 @@ namespace ecolab bool logy; double scale, o, o1; XFY():logy(false), scale(1), o(0), o1(0) {} - XFY(bool logy, double scale, double o, double o1): + XFY(bool logy, double scale, double o, double o1): logy(logy), scale(scale), o(logy? (o>0? log10(o): 0): o), o1(o1) { } double operator()(double y) const { @@ -51,7 +51,7 @@ namespace ecolab }; /// boundingBox is used explictly specify legend sizing via a bounding box relative to plot size enum Side {left, right, boundingBox}; - enum PlotType {line, bar}; + enum PlotType {line, bar, scatter, line_scatter}; struct LineStyle { @@ -140,6 +140,7 @@ namespace ecolab double xtickAngle; ///< angle (in degrees) at which xtick labels are drawn /// if |log_10 (x)| < exp_threshold, do not rescale tick value unsigned exp_threshold; + unsigned symbolEvery=1; ///< every symbolEvery data points, a symbol is plotted. /// height (or width) of an axis label in pixels double labelheight() const {return lh(width(), height());} diff --git a/src/plot.cc b/src/plot.cc index 48c93f3..5f27fb9 100644 --- a/src/plot.cc +++ b/src/plot.cc @@ -892,6 +892,7 @@ namespace ecolab switch (plotType) { case line: + case line_scatter: if (x[i].size()>1) { cairo_set_source_rgba(cairo, ls.colour.r, ls.colour.g, ls.colour.b, ls.colour.a); @@ -953,10 +954,30 @@ namespace ecolab cairo_fill(cairo); } } + default: break; + } + // now handle scatter options + switch (plotType) + { + case scatter: case line_scatter: + { + cairo::CairoSave cs(cairo); + cairo_scale(cairo,1/sx,1); + cairo_set_source_rgba(cairo, ls.colour.r, ls.colour.g, ls.colour.b, ls.colour.a); + for (size_t j=0; j0.5*(minx+maxx)) mx-=1.2*pango.width()/sx; - //if (logx) mx=(mx); cairo_rectangle(cairo,mx,my,pango.width()/sx,pango.height()); cairo_set_source_rgb(cairo,1,1,1); cairo_fill(cairo); @@ -992,7 +1012,6 @@ namespace ecolab cairo_move_to(cairo,mx,my+pango.height()); pango.show(); } - } if (legend) drawLegend(cairo,width,height);