typst/schule/mathe/tests/plotting.typ

43 lines
994 B
Typst

#import "@preview/cetz:0.3.1"
#import "@preview/cetz-plot:0.1.0": plot, chart
#cetz.canvas({
// Your plot/chart code goes here
plot.plot(
size: (2, 2),
x-tick-step: none,
y-tick-step: none,
{
plot.add(((0, 0), (1, 1), (2, .5), (4, 3)))
},
)
})
#cetz.canvas({
let opts = (x-tick-step: none, y-tick-step: none, size: (2, 1))
let data = plot.add(((-1, -1), (1, 1)), mark: "o")
for name in (none, "school-book", "left", "scientific") {
plot.plot(axis-style: name, ..opts, data, name: "plot")
}
})
#cetz.canvas({
import cetz.draw: *
import cetz.plot: *
// Erstelle eine Plotumgebung
plot.plot(
size: (4, 4),
x-tick-step: none,
y-tick-step: none,
{
// Beispiel einer Funktionsschar (Scharparameter a):
for a in (-2, -1, 0, 1, 2) {
plot.add(domain: (-2 * calc.pi, 2 * calc.pi),
t => (t, a * calc.sin(t)), // Hier f(x) = a * sin(x)
mark: "o")
}
},
)
})