FHist.jl icon indicating copy to clipboard operation
FHist.jl copied to clipboard

[FR] Plotting recipe for a curve over a histogram

Open mmikhasenko opened this issue 1 year ago • 7 comments
trafficstars

I worked on plotting the recipe and dispatch in Plots.jl using Hist1D. The recipe might below on this package

  • model with data: WithData object, and
data = randn(1000);
h = Hist1D(data; binedges=range(-5,5, 100));
model_fun(x) = length(data) * exp(-x^2 / 2) / sqrt(2π);
plot(h, seriestype=:stepbins)
plot!(model_fun, WithData(h.binedges[1]), lw=2)

384034099-1651cb59-93e2-4956-a4b7-11a0a59d0650

  • curvedfitwithpulls for distribution with the pulls
data = log.(1 .+ (exp(1) - 1) .* rand(n))
best_model(x) = exp(x) / (exp(1)-1)
h = Hist1D(data; binedges=1.1:0.1:2.5))
curvedfitwithpulls(h0, best_model, xlab = "X-axis", ylab = "Y-axis")

384031006-cbcb7600-1991-4448-805b-372b1222ae6e

mmikhasenko avatar Nov 07 '24 15:11 mmikhasenko