Function
x coordinate to start from
x coordinate to end at
Number of points to calculate
/// http://blackedder.github.io/ggplotd/images/function.png import std.random : uniform; import std.typecons : Tuple; import ggplotd.stat : statFunction; import ggplotd.ggplotd : GGPlotD; import ggplotd.geom : geomLine, geomPoint; import ggplotd.range : mergeRange; auto f = (double x) { return x / (1 + x); }; auto aes = statFunction(f, 0.0, 10); auto gg = GGPlotD().put(geomLine(aes)); // Generate some noisy points auto f2 = (double x) { return x / (1 + x) * uniform(0.75, 1.25); }; auto aes2 = f2.statFunction(0.0, 10, 25); // Show points in different colour auto withColour = Tuple!(string, "colour")("aquamarine").mergeRange(aes2); gg = gg.put(withColour.geomPoint); gg.save("function.png");
Create Aes based on a function