Skip to content

Commit db8b30a

Browse files
authored
Fix labels in paginated plots with renamed layout scale (#661)
The previous reftest didn't catch this because it accidentally did a meaningless conversion (uppercasing letters that were already uppercase) ```julia df = (; subject = [1, 1, 2, 2], group = ["A", "B", "A", "B"], x = 1:4, y = 5:8, ) spec = data(df) * mapping(:x, :y, layout = (:subject, :group) => tuple) * visual(Scatter) scls = scales( Layout = (; categories = [(1, "A") => "One A", (2, "A") => "Two A", (1, "B") => "One B", (2, "B") => "Two B"] ) ) draw(spec, scls) draw(paginate(spec, scls, layout = 3), 1) ``` ## Before <img width="593" alt="image" src="https://github.com/user-attachments/assets/baa9f727-09ac-493c-b70b-40fc6048a609" /> ## After <img width="604" alt="image" src="https://github.com/user-attachments/assets/94804856-9a6b-4ea3-b3d0-6d8fbe08079e" />
1 parent cdf4595 commit db8b30a

File tree

6 files changed

+20
-2
lines changed

6 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## v0.10.7 - 2025-05-27
6+
7+
- Fixed facet labels in paginated plots with a `Layout` scale in which categories were also relabeled using the `categories = pairs` mechanism [#661](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/661).
8+
59
## v0.10.6 - 2025-05-21
610

711
- If available, column metadata with the key `"label"` will be used instead of the column name for determining a mapping's label [#660](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/660).

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "AlgebraOfGraphics"
22
uuid = "cbdf2221-f076-402e-a563-3d30da359d67"
33
authors = ["Pietro Vertechi", "Julius Krumbiegel"]
4-
version = "0.10.6"
4+
version = "0.10.7"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

src/paginate.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ function paginate_axes_grid(agrid::Matrix{AxisSpecEntries}; layout = nothing, ro
130130
paginated = Matrix{AxisSpecEntries}[]
131131
dvalues = datavalues(scale)
132132
pvalues = plotvalues(scale)
133+
dlabels = datalabels(scale)
134+
133135
for groupindices in Iterators.partition(eachindex(dvalues, pvalues), layout)
134136
# TODO: should the original wrap style be preserved? may depend on type, not everything will work
135137
wrapped_positions = apply_palette(wrapped(), 1:length(groupindices))
@@ -139,7 +141,7 @@ function paginate_axes_grid(agrid::Matrix{AxisSpecEntries}; layout = nothing, ro
139141
dvalues[groupindices],
140142
wrapped_positions,
141143
scale.label,
142-
(Accessors.@set props.categories = nothing), # categories are already baked in and should not be reapplied later
144+
(Accessors.@set props.categories = dvalues[groupindices] .=> dlabels[groupindices]),
143145
scale.aes,
144146
)
145147
new_catscales = merge_in_scale(catscales, AesLayout, sliced_scale)

test/reference_tests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,18 @@ let
12211221
draw(paginated, i)
12221222
end
12231223
end
1224+
1225+
paginated_2 = AlgebraOfGraphics.paginate(
1226+
spec,
1227+
scales(Layout = (; categories = cats -> reverse(cats) .=> ["Eee", "Ddd", "Ccc", "Bbb", "Aaa"]));
1228+
layout = 3
1229+
)
1230+
1231+
for i in 1:length(paginated_2)
1232+
reftest("pagination category labels layout page $i") do
1233+
draw(paginated_2, i)
1234+
end
1235+
end
12241236
end
12251237

12261238
let
Loading
Loading

0 commit comments

Comments
 (0)