diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a22892e7..bc865753a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## v0.8.10 -2024-09-24 + +- Fixed markercolor in `ScatterLines` legends when it did not match `color` [#567](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/567). + ## v0.8.9 - 2024-09-24 - Added ability to include layers in the legend without using scales by adding `visual(label = "some label")` [#565](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/565). diff --git a/Project.toml b/Project.toml index 3ef903a41..fde19f21c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AlgebraOfGraphics" uuid = "cbdf2221-f076-402e-a563-3d30da359d67" authors = ["Pietro Vertechi", "Julius Krumbiegel"] -version = "0.8.9" +version = "0.8.10" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" diff --git a/src/guides/legend.jl b/src/guides/legend.jl index a6b3f72c4..6f3e2e37c 100644 --- a/src/guides/legend.jl +++ b/src/guides/legend.jl @@ -330,15 +330,17 @@ function legend_elements(T::Type{Scatter}, attributes, scale_args::MixedArgument end function legend_elements(T::Type{ScatterLines}, attributes, scale_args::MixedArguments) + color = _get(T, scale_args, attributes, :color) + markercolor = _get(T, scale_args, attributes, :markercolor) [ LineElement( - color = _get(T, scale_args, attributes, :color), + color = color, linestyle = _get(T, scale_args, attributes, :linestyle), linewidth = _get(T, scale_args, attributes, :linewidth), linepoints = [Point2f(0, 0.5), Point2f(1, 0.5)], ), MarkerElement( - color = _get(T, scale_args, attributes, :color), + color = markercolor === Makie.automatic ? color : markercolor, markerpoints = [Point2f(0.5, 0.5)], marker = _get(T, scale_args, attributes, :marker), markerstrokewidth = _get(T, scale_args, attributes, :strokewidth), diff --git a/test/reference_tests.jl b/test/reference_tests.jl index a927c4be9..b62e61325 100644 --- a/test/reference_tests.jl +++ b/test/reference_tests.jl @@ -995,3 +995,9 @@ reftest("manual legend order") do @test_throws ErrorException legend!(f[1, 4], fg, order = [:Label]) f end + +reftest("scatterlines legend") do + spec1 = data((; x = 1:10, y = cos.(1:10))) * mapping(:x, :y) * visual(ScatterLines, color = :red, label = "markercolor auto") + spec2 = data((; x = 1:10, y = cos.(1:10) .+ 2)) * mapping(:x, :y) * visual(ScatterLines, color = :blue, markercolor = :cyan, label = "markercolor cyan") + draw(spec1 + spec2) +end diff --git a/test/reference_tests/scatterlines legend ref.png b/test/reference_tests/scatterlines legend ref.png new file mode 100644 index 000000000..e9984ff59 Binary files /dev/null and b/test/reference_tests/scatterlines legend ref.png differ