How to add `PGFPlotsX.Coordinates()` object to raw LaTeX command?

tapyu
Sat, 11 Oct 2025 14:26:48 +0000
Visualization

#!/usr/bin/env julia
# using Pkg; Pkg.add("PGFPlotsX")  # run once

using PGFPlotsX

empty!(PGFPlotsX.CUSTOM_PREAMBLE)
push!(PGFPlotsX.CUSTOM_PREAMBLE, raw"\usetikzlibrary{calc,spy}")

origin = PGFPlotsX.Coordinate(0, 0)
dest   = PGFPlotsX.Coordinate(5, 0)

pic = @pgf TikzPicture(
    { "spy using outlines" => "{circle, magnification=7, size=3cm, connect spies}" },
    [raw"\draw[->, very thick] ", origin, " -- ", dest, ";"],
    raw"\path (2,2) node[fill, rectangle, inner sep=2pt, minimum height=1cm] (n) {};",
    raw"\draw[densely dotted] (n.south west) -- (n.south west |- 0,0);",
    raw"\draw[densely dotted] (n.south east) -- (n.south east |- 0,0);",
    raw"\spy on ($(n.south east |- 0,0)!0.5!(n.south west |- 0,0)$) in node at (3,-2);"
)

doc = TikzDocument(pic)
PGFPlotsX.save("figure.tex", doc)

The line

[raw"\draw[->, very thick] ", origin, " -- ", dest, ";"]

is what I intuitively want: use origin and dest coordinates as input of \draw. How to make it work?

1 post - 1 participant