Skip to content

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

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions