How to add percent sign to axis numbers in lilaq/zero

Hi, I’m using lilaq for some data tables that uses zero in displaying the numbers on the axis. I want the numbers on the y-axis to have a percent sign after them, could someone help me how to achieve this? I’m not even sure if should be done in lilaq or in zero, any help is appreciated :)

This is an example:

#import "@preview/lilaq:0.5.0" as lq

#let distribution = ((0, 0.15), (1, 0.30), (2, 0.25))

#lq.diagram(
  lq.plot(distribution.map(x => x.at(0)), distribution.map(y => calc.round(y.at(1) * 100))),
)

Hey @Heyooooooo ;)

There are two solutions to this:

Using a show rule

The following show rule selects tick labels on the y-axis which aren’t subtick labels and adds $%$ to them:

#show: lq.show_(
  lq.tick-label.with(kind: "y", sub: false),
  it => it + $%$
)

#lq.diagram(
  lq.plot(distribution.map(x => x.at(0)), distribution.map(y => calc.round(y.at(1) * 100))),
)

Using the formatters suffix parameter

The other option is to use lq.tick-format.linear.suffix. Note however, that

  • for 0, the suffix is omitted (printing no %)
  • for 1, only the suffix is printed (printing % instead of 1%)
#lq.diagram(
  yaxis: (
    format-ticks: lq.tick-format.linear.with(suffix: "%")
  ),
  lq.plot(distribution.map(x => x.at(0)), distribution.map(y => calc.round(y.at(1) * 100))),
)

For this reason I would recommend the first option.

I hope that helps!