Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stairs #573

Merged
merged 8 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.13 - 2024-10-21

- Added aesthetics for `Stairs` [#573](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/573).

## v0.8.12 - 2024-10-07

- Added `legend` keyword in `visual` to allow overriding legend element attributes [#570](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/570).
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.12"
version = "0.8.13"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
11 changes: 11 additions & 0 deletions src/aesthetics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,14 @@ function aesthetic_mapping(::Type{Hist}, ::Normal)
:strokecolor => AesColor,
])
end

aesthetic_mapping(::Type{Stairs}, ::Normal) = aesthetic_mapping(Stairs, 1)
aesthetic_mapping(::Type{Stairs}, ::Normal, ::Normal) = aesthetic_mapping(Stairs, 2)

function aesthetic_mapping(::Type{Stairs}, N::Int)
dictionary([
pointlike_positionals(N)...,
:color => AesColor,
:linestyle => AesLineStyle,
])
end
2 changes: 1 addition & 1 deletion src/guides/legend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ function legend_elements(T::Type{Heatmap}, attributes, scale_args::MixedArgument
)]
end

function legend_elements(T::Type{<:Union{HLines,VLines,Lines,LineSegments,Errorbars,Rangebars,Wireframe,ABLines,ECDFPlot}}, attributes, scale_args::MixedArguments)
function legend_elements(T::Type{<:Union{HLines,VLines,Lines,LineSegments,Errorbars,Rangebars,Wireframe,ABLines,ECDFPlot,Stairs}}, attributes, scale_args::MixedArguments)

is_vertical = T === VLines || (T <: Union{Errorbars,Rangebars} && _get(T, scale_args, attributes, :direction) === :y)
# TODO: seems errorbars and rangebars are missing linestyle in Makie, once this is fixed, remove this
Expand Down
11 changes: 11 additions & 0 deletions test/reference_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1007,3 +1007,14 @@ reftest("legend element overrides") do
visual(Scatter, legend = (; markersize = 30))
draw(spec)
end

reftest("stairs") do
spec = mapping(
1:10,
[1, 4, 3, 7, 5, 3, 2, 4, 3, 7],
color = repeat(["A", "B"], inner = 5),
linestyle = repeat(["A", "B"], inner = 5),
) *
visual(Stairs)
draw(spec)
end
Binary file added test/reference_tests/stairs ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading