density

AbstractPlotting.densityFunction
density(values; npoints = 200, offset = 0.0, direction = :x)

Plot a kernel density estimate of values. npoints controls the resolution of the estimate, the baseline can be shifted with offset and the direction set to :x or :y. bandwidth and boundary are determined automatically by default.

Attributes

Available attributes and their defaults for Density{T} where T are:

  bandwidth     AbstractPlotting.Automatic()
  boundary      AbstractPlotting.Automatic()
  color         :gray85
  direction     :x
  npoints       200
  offset        0.0
  strokearound  false
  strokecolor   :black
  strokewidth   1
source

Examples

using CairoMakie

f = Figure(resolution = (800, 600))
Axis(f[1, 1])

density!(randn(200))

f
using CairoMakie

f = Figure(resolution = (800, 600))
Axis(f[1, 1])

density!(randn(200), direction = :y, npoints = 10)

f
using CairoMakie

f = Figure(resolution = (800, 600))
Axis(f[1, 1])

density!(randn(200), color = (:red, 0.3),
    strokecolor = :red, strokewidth = 3, strokearound = true)

f
using CairoMakie

f = Figure(resolution = (800, 600))
Axis(f[1, 1])

vectors = [randn(1000) .+ i/2 for i in 0:5]

for (i, vector) in enumerate(vectors)
    density!(vector, offset = -i/4, color = (:slategray, 0.4),
        bandwidth = 0.1)
end

f