diff --git a/ext/recipes/lplot.jl b/ext/recipes/lplot.jl index 12e7642..9268ffd 100644 --- a/ext/recipes/lplot.jl +++ b/ext/recipes/lplot.jl @@ -205,5 +205,30 @@ function LegendMakie.lplot!( Makie.lines!(ax, com_report.energy, com_report.values, linewidth = 4, color = :red, linestyle = :dash, label = LaTeXStrings.latexstring("\\fontfamily{Roboto}" * com_report.label_fit)) Makie.axislegend(ax, position = legend_position) + fig +end + + +function LegendMakie.lplot!(args...; watermark::Bool = false, kwargs...) + + fig = Makie.current_figure() + + #create plot + ax = if !isnothing(Makie.current_axis()) + Makie.current_axis() + else + Makie.Axis(fig[1,1], + titlesize = 18, + titlegap = 1, + titlealign = :right + ) + end + + # use built-in method as fallback if existent, tweak appearance + Makie.plot!(args...; kwargs...) + + # add watermarks + watermark && LegendMakie.add_watermarks!(; kwargs...) + fig end \ No newline at end of file diff --git a/test/Project.toml b/test/Project.toml index 1f83dd5..77a259d 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -5,6 +5,7 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" LegendSpecFits = "18221496-77af-46cf-bab8-820da09f7f97" Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" RadiationDetectorSignals = "bf2c0563-65cf-5db2-a620-ceb7de82658c" +StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" diff --git a/test/test_lplot.jl b/test/test_lplot.jl index 76d68e2..8452002 100644 --- a/test/test_lplot.jl +++ b/test/test_lplot.jl @@ -5,6 +5,7 @@ using Makie import LegendSpecFits import Distributions +import StatsBase import Unitful: @u_str using Test @@ -16,7 +17,7 @@ using Test # test default watermark ax = Axis(fig[1,1]) - hist!(ax, randn(10000)) + @test_nowarn lplot!(StatsBase.fit(StatsBase.Histogram, randn(10000))) @test_nowarn LegendMakie.add_watermarks!() # test alternative watermark