Skip to content

Commit

Permalink
Fixed markercolor in ScatterLines legends when it did not match `co…
Browse files Browse the repository at this point in the history
…lor` (#567)
  • Loading branch information
jkrumbiegel authored Sep 24, 2024
1 parent 8edc4ff commit 6ab480f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 4 additions & 2 deletions src/guides/legend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 6 additions & 0 deletions test/reference_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file added test/reference_tests/scatterlines legend ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

2 comments on commit 6ab480f

@jkrumbiegel
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/115829

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.8.10 -m "<description of version>" 6ab480f7347ae1ec595bae9234d9bf17247bc192
git push origin v0.8.10

Please sign in to comment.