Skip to content

Commit

Permalink
plot: Set justify to false for plot labels
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf committed Dec 4, 2023
1 parent c3ab713 commit 140ddcd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
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.

0 comments on commit 140ddcd

Please sign in to comment.