Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Plotting recipe for a curve over a histogram #126

Open
mmikhasenko opened this issue Nov 7, 2024 · 7 comments · May be fixed by #127
Open

[FR] Plotting recipe for a curve over a histogram #126

mmikhasenko opened this issue Nov 7, 2024 · 7 comments · May be fixed by #127

Comments

@mmikhasenko
Copy link

mmikhasenko commented Nov 7, 2024

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 mmikhasenko linked a pull request Nov 7, 2024 that will close this issue
2 tasks
@Moelf
Copy link
Owner

Moelf commented Nov 7, 2024

for some reason images are gone

@mmikhasenko
Copy link
Author

mmikhasenko commented Nov 8, 2024

The images are only visible to me for some funny reason (gone in incognito tab)
Just updated

@Moelf
Copy link
Owner

Moelf commented Nov 11, 2024

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.

@mmikhasenko mmikhasenko changed the title [FR] Plotting recipe, fit on histogram [FR] Plotting recipe for a curve over a histogram Nov 11, 2024
@mmikhasenko
Copy link
Author

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 WithData struct.

I think we can start with that, let me wipe out the curvedfitwithpulls making the PR small

@Moelf
Copy link
Owner

Moelf commented Nov 11, 2024

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?

@mmikhasenko
Copy link
Author

yea + plotting style

@Moelf
Copy link
Owner

Moelf commented Nov 11, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants