[FR] Plotting recipe for a curve over a histogram
I worked on plotting the recipe and dispatch in Plots.jl using Hist1D.
The recipe might below on this package
- model with data:
WithDataobject, 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)
curvedfitwithpullsfor 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")
for some reason images are gone
The images are only visible to me for some funny reason (gone in incognito tab) Just updated
my thoughts are the following:
- I like this feature and I think they're useful and I'm sure they are generally useful
- I don't like this feature is purely a plotting recipe, i.e. users can't extract the numbers from fitting.
It feels to me that, the "fitting with data" and "pull" should be their own objects, and they should have their own plotting recipe in a statistical package. And then, users can plot them as overlay on top of the histograms defined in this package.
Thanks for the replies
The piece of information that the recipe creates is a pulls histogram.
This histogram indeed can be useful as it is. There you are completely right - there should be a separate method creating just a histogram.
The other concern might come from unclear naming on my side:
- the recipe does not fit anything, just scales by a number give to the
WithDatastruct.
I think we can start with that, let me wipe out the curvedfitwithpulls making the PR small
the recipe does not fit anything, just scales by a number give to the WithData struct.
oh I see, then in that case it feels even less useful to be a standalone thing? if it's just plotting a function evaluated at a set of x-points and scale it?
yea + plotting style
in this case I would suggest make that a standalone thing, such as https://github.com/aminnj/yahist
basically, FHist.jl feels like it should focus on histograms, not X + histograms.
I'm happy to add extensions or help maintaining them if you need X from histograms or X to histograms kind of functionality, but I feel like adding all X+histogram visualization is the wrong organization