From 714cf7a383a8a87d75ac5875eb42f0e650315274 Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Wed, 1 May 2024 04:10:33 -0400 Subject: [PATCH] add `axislegend` method that inputs an axis and a title (#3808) --- CHANGELOG.md | 1 + src/makielayout/blocks/legend.jl | 4 +++- test/makielayout.jl | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b12fe5d985..cd81d691795 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] +- Add `axislegend(ax, "title")` method [#3808](https://github.com/MakieOrg/Makie.jl/pull/3808) - Improved thread safety of rendering with CairoMakie (independent `Scene`s only) by locking FreeType handles [#3777](https://github.com/MakieOrg/Makie.jl/pull/3777). ## [0.20.9] - 2024-03-29 diff --git a/src/makielayout/blocks/legend.jl b/src/makielayout/blocks/legend.jl index d0b42b73c14..28897c6dd98 100644 --- a/src/makielayout/blocks/legend.jl +++ b/src/makielayout/blocks/legend.jl @@ -630,12 +630,14 @@ end axislegend(ax = current_axis(); kwargs...) = axislegend(ax, ax; kwargs...) axislegend(title::AbstractString; kwargs...) = axislegend(current_axis(), current_axis(), title; kwargs...) +axislegend(ax, title::AbstractString; kwargs...) = axislegend(ax, ax, title; kwargs...) """ axislegend(ax, args...; position = :rt, kwargs...) axislegend(ax, args...; position = (1, 1), kwargs...) axislegend(ax = current_axis(); kwargs...) axislegend(title::AbstractString; kwargs...) + axislegend(ax, title::AbstractString; kwargs...) Create a legend that sits inside an Axis's plot area. @@ -836,4 +838,4 @@ function attribute_examples(::Type{Legend}) ), ], ) -end \ No newline at end of file +end diff --git a/test/makielayout.jl b/test/makielayout.jl index 5c50e90632c..945dfdbbf02 100644 --- a/test/makielayout.jl +++ b/test/makielayout.jl @@ -259,6 +259,7 @@ end leg = axislegend(ax, position = (0.4, 0.8)) @test leg.halign[] == 0.4 @test leg.valign[] == 0.8 + @test_nowarn axislegend(ax, "foo") # issue 2530 end # issue 2005