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

plot: Set justify: false for plot labels #373

Merged
merged 1 commit into from
Dec 5, 2023
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
20 changes: 10 additions & 10 deletions src/lib/axes.typ
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
if label != none {
let label-pos = vector.add(tick-start,
vector.scale(tic-dir, -style.tick.label.offset))
content(label-pos, [#label],
content(label-pos, par(justify: false, [#label]),
anchor: if style.tick.label.anchor == auto {anchor}
else {style.tick.label.anchor},
angle: style.tick.label.angle)
Expand Down Expand Up @@ -435,7 +435,7 @@
group(
content(
position,
axis.label,
par(justify: false, axis.label),
angle: angle,
padding: style.label.offset
),
Expand Down Expand Up @@ -488,8 +488,8 @@
let y-x = value-on-axis(x-axis, y-position) * w

let axis-settings = (
(x-axis, "north", (auto, x-y), (0, 1), "x"),
(y-axis, "east", (y-x, auto), (1, 0), "y"),
(x-axis, "north", (auto, x-y), (0, 1), "x"),
(y-axis, "east", (y-x, auto), (1, 0), "y"),
)

line((-padding.left, x-y), (w + padding.right, x-y),
Expand All @@ -500,8 +500,8 @@
if style.label.anchor == auto {
anchor = "north-west"
}
content((rel: (0, -style.tick.label.offset), to: "x-axis.end"),
anchor: anchor, x-axis.label)
content((rel: (0, -style.label.offset), to: "x-axis.end"),
anchor: anchor, par(justify: false, x-axis.label))
}

line((y-x, -padding.bottom), (y-x, h + padding.top),
Expand All @@ -512,8 +512,8 @@
if style.label.anchor == auto {
anchor = "south-east"
}
content((rel: (-style.tick.label.offset, 0), to: "y-axis.end"),
anchor: anchor, y-axis.label)
content((rel: (-style.label.offset, 0), to: "y-axis.end"),
anchor: anchor, par(justify: false, y-axis.label))
}

// If both axes cross at the same value (mostly 0)
Expand Down Expand Up @@ -565,12 +565,12 @@
origin-drawn = true
content(vector.add((x, y),
vector.scale((1, 1), -style.tick.label.offset / 2)),
[#label], anchor: "north-east")
par(justify: false, [#label]), anchor: "north-east")
}
} else {
content(vector.add(tick-begin,
vector.scale(tic-dir, -style.tick.label.offset)),
[#label], anchor: anchor)
par(justify: false, [#label]), anchor: anchor)
}
}
}
Expand Down
Binary file modified tests/plot/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.
Binary file modified tests/plot/ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.