Cetz-plot and cetz.draw.content with anchors behaving badly?

Why is box “B” placed the way it is? I would have expected the box to be with its southwest corner at (0,0).

#import "@preview/cetz:0.4.2": canvas, draw
#import "@preview/cetz-plot:0.1.3": plot

#canvas(length: 1cm, {
  let (cos, sin) = (calc.cos, calc.sin)
  let A = 1.05
  draw.set-style(axes: (
    minor-grid: (stroke: gray.lighten(70%) + 0.1pt)
  ))
  
  plot.plot(
    size: (6, 6),
    x-minor-tick-step: 0.1,
    y-minor-tick-step: 0.1,
    x-min: -A, x-max: A, x-tick-step: 0.5, x-grid: "both",
    y-min: -A, y-max: A, y-tick-step: 0.5, y-grid: "both",
    {
      plot.annotate({
        draw.content((0,0), box("A", stroke:1pt))
        draw.content((0,0), box("B", stroke:1pt), anchor:"south-west", padding:0)
      })
      plot.add(
        domain: (0, 2 * calc.pi),
        t => (cos(t), sin(t)),
        fill: true,
        style: (fill: blue.lighten(95%),
                stroke: blue)
      )
    }
  )
})

Someone smarter will have to correct me, but it seems "north" is towards negative y.

It works “as expected” if you flip the y-axis:

#import "@preview/cetz:0.4.2": canvas, draw
#import "@preview/cetz-plot:0.1.3": plot

#canvas(length: 1cm, {
  import calc: sin, cos
  let A = 1.05
  draw.set-style(axes: (
    minor-grid: (stroke: gray.lighten(70%) + 0.1pt)
  ))
  
  plot.plot(
    size: (6, 6),
    x-minor-tick-step: 0.1,
    y-minor-tick-step: 0.1,
    x-min: -A, x-max: A, x-tick-step: 0.5, x-grid: "both",
    y-min: A, y-max: -A, y-tick-step: 0.5, y-grid: "both",
    {
      plot.annotate({
        draw.content((0,0), box("A", stroke:1pt))
        draw.content((0,0), box("B", stroke:1pt), anchor:"south-west", padding:0)
      })
      plot.add(
        domain: (0, 2 * calc.pi),
        t => (cos(t), sin(t)),
        fill: true,
        style: (fill: blue.lighten(95%),
                stroke: blue)
      )
    }
  )
})

Sidenote:
Instead of manually assigning sin and cos, you can import them:

#canvas(length: 1cm, {
  import calc: sin, cos
  ...
1 Like