kplot_attach_smooth —
assign smoothed plot data to plotting context
#include <cairo.h>
#include <kplot.h>
int
kplot_attach_smooth(const struct kplot
*p, struct kdata *d, enum
kplottype t, const struct kdatacfg *cfg,
enum ksmthtype smthtype, const struct
ksmthcfg *smth);
The kplot_attach_smooth function assigns a
smoothed data source d to a plotting context
p, reference-counting the data source in the process.
See
kplot_attach_data(3)
for details on the p, d,
t, and cfg parameters. The
remaining smthtype and smth
configure smoothing options, which manipulate the data as it's being drawn.
The following smoothing types are available:
KSMOOTH_MOVAVG
- Replace each point with the average of the surrounding
movsamples points. If
movsamples if not an odd number, it is increased by
one. If the point is not surrounded completely by
movsamples, say by being at the initial or trailing
points of the data set, or the points surrounding are not valid numbers,
then the point is not averaged.
KSMOOTH_CDF
- Compute the empirical CDF from all valid points of the set. This will
normalise the y-values to within the unit interval.
KSMOOTH_PMF
- Normalise the y-values as probabilities of valid points of the set.
kplot_attach_smooth returns 0 if
allocation of internal structures fails due to memory exhaustion. In this
case, all allocations and references will be dropped.
The KSMOOTH_CDF an
KSMOOTH_PMF has undefined behaviour for negative
probabilities.