Skip to content

Anchors don't work properly in annotation() context #187

Open

Description

@jason-sachs
#import "@preview/cetz:0.5.2"
#import "@preview/cetz-plot:0.1.4"

#let tryit(xmin, xmax, yscale) = {
    cetz.canvas({
        import cetz.draw: *
        import cetz-plot: plot

        plot.plot(
            size: (10, 6),
            y-grid: "both", y-min:0.3*yscale, y-max:0.7*yscale, y-tick-step:0.1, y-minor-tick-step:0.02,
            x-min:xmin, x-max:xmax, x-tick-step: (xmax - xmin)/5,

            name: "plot",
            axis-style: "school-book",
            {
                let v(a) = {xmin + (xmax - xmin) * a}
                plot.add(((v(0),0.3*yscale),(v(0.2),0.6*yscale),(v(0.3),0.6*yscale),(v(0.5),0.5*yscale),(v(1),0.7*yscale)))
                let mypoint = (v(0.5),0.5*yscale)
                plot.add((mypoint,), mark:"o")
                plot.annotate({
                    for anc in ("north-west", "north-east","south-west","south-east") {
                        content(mypoint, anc, anchor:anc)        
                    }
                })
            }
        )
    })
}

#tryit(130, 180, 1)

#tryit(10, 18, 1)

#tryit(10, 18, 2)
Image

Activity

  1. johannes-wolf commented on Jul 3, 2026

    @johannes-wolf
    Member

    This is a known issue that needs some rewrite of how cetz-plot converts to plot-local coordinates.
    With cetz 5.* that mechanism exists in cetz. There is a WIP PR here: #135.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions