Skip to content

Commit 3ca2525

Browse files
authored
Merge pull request #39 from legend-exp/singlefits
Plot best fit from `fit_peaks` only for the range of the histogram
2 parents 547b67a + af859c6 commit 3ca2525

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/LegendMakieLegendSpecFitsExt.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ module LegendMakieLegendSpecFitsExt
310310
)
311311

312312
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)
313-
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))
313+
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))
314314

315315
# show individual components of the Gaussian mixtures
316316
if show_components
@@ -511,7 +511,7 @@ module LegendMakieLegendSpecFitsExt
511511
)
512512

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

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

0 commit comments

Comments
 (0)