Skip to content

Commit b904a97

Browse files
authored
Merge pull request #37 from legend-exp/sf
Add option to include survival fraction in title of survival plot
2 parents cd7b4c4 + c6ea8db commit b904a97

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

ext/LegendMakieLegendSpecFitsExt.jl

+3-4
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ module LegendMakieLegendSpecFitsExt
235235
xticks = (ceil(first(xlims)/10)*10):10:(floor(last(xlims)/10)*10),
236236
ylims = nothing, row::Int = 1, col::Int = 1, xlabel = "Energy (keV)",
237237
title::AbstractString = "", yscale = Makie.log10, show_residuals::Bool = true,
238-
watermark::Bool = true, final::Bool = true, kwargs...
238+
sf_in_title::Bool = true, watermark::Bool = true, final::Bool = true, kwargs...
239239
)
240240

241241
fig = Makie.current_figure()
@@ -252,9 +252,8 @@ module LegendMakieLegendSpecFitsExt
252252
ylims = (ylim_min, ylim_max)
253253
end
254254

255-
ax = Makie.Axis(g[1,1], yticks = (exp10.(0:10), "1" .* join.(fill.("0", 0:10))),
256-
ylabel = "Counts / $(round(step(first(report.survived.h.edges)), digits=2)) keV",
257-
limits = (xlims, ylims); yscale, xlabel, title, xticks)
255+
ax = Makie.Axis(g[1,1], ylabel = "Counts / $(round(step(first(report.survived.h.edges)), digits=2)) keV",
256+
limits = (xlims, ylims); yscale, xlabel, title = sf_in_title ? "$title Survival fraction: $(round(report.sf * 100, digits = 2))%" : title, xticks)
258257

259258
before_data = Makie.plot!(ax, report.survived.h, color = (:gray, 0.5), fillto = 0.5)
260259
before_fit = Makie.lines!(ax, range(xlims..., length = 1000), x -> report.survived.f_fit(x) * step(first(report.survived.h.edges)), color = :black)

test/test_lplot.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ end
202202
e_cal = 1.5u"keV" .* randn(100_000) .+ 2614.5u"keV"
203203
result_peaks_ds, report_peaks_ds = LegendSpecFits.get_peaks_survival_fractions(
204204
aoe, e_cal, [2614.5u"keV"], [:Tl208FEP], [(35.0u"keV",35.0u"keV")], -5.0)
205-
@test_nowarn LegendMakie.lplot(report_peaks_ds[:Tl208FEP], title = "Test")
205+
@test_nowarn LegendMakie.lplot(report_peaks_ds[:Tl208FEP], sf_in_title = true, title = "Test")
206+
@test_nowarn LegendMakie.lplot(report_peaks_ds[:Tl208FEP], sf_in_title = false, title = "Test")
207+
@test_nowarn LegendMakie.lplot(report_peaks_ds, title = "Test")
208+
@test_nowarn LegendMakie.lplot(report_peaks_ds, sf_in_title = false, title = "Test")
206209
end
207210

208211
@testset "LQ plots" begin

0 commit comments

Comments
 (0)