Skip to content

Commit

Permalink
Add fillto to BarPlot aesthetics (#535)
Browse files Browse the repository at this point in the history
Fixes #519
  • Loading branch information
jkrumbiegel authored Aug 26, 2024
1 parent d2b25e6 commit 4662098
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Added `fillto` to `BarPlot` aesthetics [#535](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/535).

## v0.8.3 - 2024-08-23

- Fixed incorrect x/y axis assignment for the `violin` plot type [#528](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/528).
Expand Down
8 changes: 6 additions & 2 deletions src/aesthetics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ function aesthetic_mapping(::Type{BarPlot}, N::Int)
positionals = if N == 1
[
1 => :direction => dictionary([
:y => AesY,
:x => AesX,
:y => AesY,
:x => AesX,
])
]
else
Expand All @@ -107,6 +107,10 @@ function aesthetic_mapping(::Type{BarPlot}, N::Int)
]),
:dodge => AesDodge,
:stack => AesStack,
:fillto => :direction => dictionary([
:y => AesY,
:x => AesX,
]),
])
end

Expand Down
12 changes: 12 additions & 0 deletions test/reference_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ reftest("barplot row layout") do
data((; x = ["A", "B", "C"], y = 1:3, z = ["X", "Y", "Z"])) * mapping(:x, :y; row = :z) * visual(BarPlot) |> draw
end

reftest("barplot fillto") do
df = (; x = 11:20, upper = 1:10, lower = 0:-1:-9)
spec = data(df) * mapping(:x, :upper, fillto = :lower) * visual(BarPlot)
draw(spec)
end

reftest("barplot fillto direction x") do
df = (; x = 11:20, upper = 1:10, lower = 0:-1:-9)
spec = data(df) * mapping(:x, :upper, fillto = :lower) * visual(BarPlot, direction = :x)
draw(spec)
end

for (plottype, name) in zip([Lines, Scatter], ["lines", "scatter"])
reftest("$name") do
data((; x = [1, 3, 2, 4], y = ["A", "B", "C", "D"])) * mapping(:x, :y) * visual(plottype) |> draw
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/reference_tests/barplot fillto ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4662098

Please sign in to comment.