You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in this example, i'd like to pass name to plot.add in order to draw lines between e.g. "n_B-T=1.50%" and "n_B-T=2.50%" but i'm getting an unexpected argument error. for now, i'm hard-coding the start/end points of the bezier curves
#import"@preview/cetz:0.3.2": canvas, draw#import"@preview/cetz-plot:0.1.1": plot#importdraw: content, line, bezier#setpage(width: auto, height: auto, margin: 8pt)
// Bose-Einstein distribution function#letn_B(x, T) = {
ifx==0orT==0 { return0.5 }
letratio=x / T1 / (calc.exp(ratio) -1) +0.5
}
#canvas({
draw.set-style(axes: (y: (label: (anchor: "south-east", angle: 90deg)), x: (label: (anchor: "north-east"))))
plot.plot(
size: (8, 7),
x-label: $"Re"(p_0)$,
y-label: $n_"B" (p_0)$,
x-min: 0,
y-min: 0,
y-max: 5,
x-tick-step: none,
y-tick-step: none,
axis-style: "left",
{
// Plot distributions for different temperatures
for (T, color) in ((0.5, red), (1, orange), (2, blue)) {
plot.add(
style: (stroke: color + 1.5pt),
domain: (0.01, 2),
samples: 150,
x => n_B(x, T),
name: "n_B-T=" + str(T), // --> this line raises unexpected argument
)
}
},
)
// Add curved arrows between intersection points
let arrow-style = (end: "stealth", stroke: 1pt, fill: black)
// First arrow (T=0.5 to T=1)
bezier(
(1.8, 1.7), // start point
(2.4, 2.4), // end point
(2, 2.3), // control point
mark: arrow-style,
name: "arrow1",
)
content("arrow1.mid", text(size: 8pt)[$2 dot T$], anchor: "south-east")
// Second arrow (T=1 to T=2)
bezier(
(2.4, 2.5), // start point
(3.5, 3.2), // end point
(2.9, 3.3), // control point
mark: arrow-style,
name: "arrow2",
)
content("arrow2.mid", text(size: 8pt)[$2 dot T$], anchor: "south-east")
})
The text was updated successfully, but these errors were encountered:
I've not added that initially because if clipped, a single plot can have a large number of separate lines. My Idea was that add-anchor is a more precise way of creating data-relative anchors. But I think I will add named plot-elements, although they might not be very useful in some scenarios.
in this example, i'd like to pass
name
toplot.add
in order to draw lines between e.g."n_B-T=1.50%"
and"n_B-T=2.50%"
but i'm getting an unexpected argument error. for now, i'm hard-coding the start/end points of thebezier
curvesThe text was updated successfully, but these errors were encountered: