kplot_attach_datas —
assign multi-plot data to plotting context
#include <cairo.h>
#include <kplot.h>
int
kplot_attach_datas(const struct kplot
*p, size_t sz, struct kdata
**d, const enum kplottype *t,
const struct kdatacfg *const *cfg,
enum kplotstype st);
The kplot_attach_datas function assigns a
"multi-data" source set d to a plotting
context p, reference-counting the data sources in the
process. See
kplot_attach_data(3)
for a more general description of attaching data. Multi-data source sets
consist of a baseline and one or more pair lines, for example, a curve and
its error bars. The most common usage is for graphing mean (the baseline)
and standard deviation above and below (pair lines) via
kdata_mean_alloc(3)
and
kdata_stddev_alloc(3).
The order in which you arrange the array parameters d,
t, and cfg: the first is for the
baseline, subsequent are for pair lines as defined by
st. The cfg argument can be
NULL (as can individual array entries); all other
parameters and indexes must not be NULL. The plot
types are as follows:
KPLOTS_YERRORLINE
- Draw a baseline (or points) using the first element in
d. The next element is used to draw error lines (or
points) above (adding to the y-position) and below (subtracting) the
baseline. Subsequent lines are ignored. Data sources are matched by bucket
index, not x-axis value, which is ignored for all pair
data sources.
KPLOTS_YERRORBAR
- Draw a baseline (or points) using the first element in
d. The next element is used to draw error lines (or
point) above (adding to the y-position) and below (subtracting) the
baseline. A bar is then drawn between these points using the line
configuration of this element. Subsequent lines are ignored. Data sources
are matched by bucket index, not x-axis value, which is
ignored for all pair data sources.
kplot_attach_datas returns 0 if allocation
of internal structures fails due to memory exhaustion, or not enough data
sources have been provided. In this case, all allocations and references
will be dropped.