Closed kdog3682 closed 5 months ago
This is actually expected behavior. The plot.annotate
content is scaled via the axes of the annotation (you can set them via axes: ("x", "y")
). If you want to draw annotations that do not use the plot's transformation, you have to use anchors and draw those elements after the plot.
Understood.
But here is another version of it.
https://typst.app/project/wqLpO0mXFqs5_qbpCwk4iA
#import "@preview/cetz:0.2.2"
#cetz.canvas({
import cetz.plot
import cetz.draw: *
plot.plot(
size: (3, 3),
x-min: -3,
x-max: 5, {
plot.add(domain: (-3, 1), (x) => x)
plot.annotate({
circle((0, 0))
// displays as ellipse
})
})
})
In this case, I feel like the annotation should automatically scale with the original plot.
Looks correct to me.
To draw outsides the plot environment and hence without its transformation use anchors:
#import "@preview/cetz:0.2.2"
#cetz.canvas({
import cetz.plot
import cetz.draw: *
plot.plot(
name: "plot",
size: (8,8),
x-min: -3,
x-max: 5, {
plot.add(domain: (-3, 1), (x) => x)
plot.add-anchor("zero", (0,0))
})
// Using anchors and drawing outsides the plot:
circle("plot.zero")
})
There is a ticket open to implement drawing fixed size objects insides a plot: cetz-package/cetz-plot#4, but this is not trivial.
https://typst.app/project/wqLpO0mXFqs5_qbpCwk4iA
The circle becomes an ellipse due to the size being larger in the x.