Skip to content

Plot best fit from fit_peaks only for the range of the histogram #39

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

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/LegendMakieLegendSpecFitsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ module LegendMakieLegendSpecFitsExt
)

Makie.hist!(ax, StatsBase.midpoints(first(report.h_cal.edges)), weights = report.h_cal.weights, bins = first(report.h_cal.edges), color = LegendMakie.DiamondGrey, label = "Amplitudes", fillto = 1e-2)
Makie.lines!(range(xlims..., length = 1000), x -> report.f_fit(x), linewidth = 2, color = :black, label = ifelse(show_label, "Best Fit" * (!isempty(report.gof) ? " (p = $(round(report.gof.pvalue, digits=2)))" : ""), nothing))
Makie.lines!(range(extrema(first(report.h_cal.edges))..., length = 1000), x -> report.f_fit(x), linewidth = 2, color = :black, label = ifelse(show_label, "Best Fit" * (!isempty(report.gof) ? " (p = $(round(report.gof.pvalue, digits=2)))" : ""), nothing))

# show individual components of the Gaussian mixtures
if show_components
Expand Down Expand Up @@ -511,7 +511,7 @@ module LegendMakieLegendSpecFitsExt
)

data = Makie.hist!(ax, StatsBase.midpoints(first(report.h.edges)), weights = report.h.weights, bins = first(report.h.edges), color = LegendMakie.DiamondGrey)
fit = Makie.lines!(range(xlims..., length = 1000), x -> report.f_fit(x) * step(first(report.h.edges)), color = :black)
fit = Makie.lines!(range(extrema(first(report.h.edges))..., length = 1000), x -> report.f_fit(x) * step(first(report.h.edges)), color = :black)

if legend_position != :none
Makie.axislegend(ax, show_label ? [data, fit] : [data],
Expand Down