cetz-plot
cetz-plot copied to clipboard
y-axis in log mode cannot go below 1e-6
When plotting in log mode, there is no way for the y-axis to go below 1e-6. Note that also the y-tick-step is necessary, as otherwise the compilation crashes due to too many ticks (is this a bug?)
#import "@preview/cetz-plot:0.1.0": plot
#import "@preview/cetz:0.3.1"
#set page(width: auto, height: auto, margin: 5mm)
#cetz.canvas(
{
plot.plot(
size: (6, 3),
y-mode: "log",
y-format: "sci",
y-tick-step: 1,
y-min: 1e-7,
{
plot.add((
(0, 1e-7),
(1, 1e-6),
(2, 1e-2),
),
mark: "o"
)
}
)
}
)
I assume this stems from the fact, that there is a floating point epsilon in cetz defined as exactly that value. One can get around this problem by rescaling the data and then scaling it back in the tick formatter. For example like this
#cetz.canvas(
{
plot.plot(
size: (6, 3),
y-mode: "log",
y-format: y => plot.formats.sci(y / 1e2),
y-tick-step: 1,
y-min: 1e-5,
{
plot.add((
(0, 1e-7),
(1, 1e-6),
(2, 1e-2),
).map(
((x, y)) => (x, y * 1e2)
),
mark: "o"
)
}
)
}
)
This is possibly related to #64