geomDensity

Draw kernel density based on the x coordinates of the data

geomDensity
(
AES
)
(
AES aes
)

Examples

/// http://blackedder.github.io/ggplotd/images/filled_density.svg
import std.array : array;
import std.algorithm : map;
import std.range : repeat, iota, chain;
import std.random : uniform;

import ggplotd.aes : Aes;
import ggplotd.geom : geomDensity;
import ggplotd.ggplotd : GGPlotD;
import ggplotd.legend : discreteLegend;
auto xs = iota(0,50,1).map!((x) => uniform(0.0,5)+uniform(0.0,5)).array;
auto cols = "a".repeat(25).chain("b".repeat(25));
auto aes = Aes!(typeof(xs), "x", typeof(cols), "colour", 
    double[], "fill" )( 
        xs, cols, 0.45.repeat(xs.length).array);
auto gg = GGPlotD().put( geomDensity( aes ) );
gg.put(discreteLegend);
gg.save( "filled_density.svg" );

Meta