diff --git a/manual.pdf b/manual.pdf index 8e7056c..ee16168 100644 Binary files a/manual.pdf and b/manual.pdf differ diff --git a/src/plot/line.typ b/src/plot/line.typ index 1aabc61..aa89623 100644 --- a/src/plot/line.typ +++ b/src/plot/line.typ @@ -186,8 +186,35 @@ /// - axes (axes): Name of the axes to use for plotting. Reversing the axes /// means rotating the plot by 90 degrees. /// - mark (string): Mark symbol to place at each distinct value of the -/// graph. Uses the `mark` style key of `style` for drawing. -/// - mark-size (float): Mark size in cavas units +/// graph. Uses the `mark` style key of `style` for drawing: +/// +/// ```cexample-vertical +/// let points(offset) = ((offset, 0), (offset, 1)) +/// +/// plot.plot(size: (12, 2), axis-style: none, { +/// plot.add(points(0), mark: "*") // same as "x" +/// plot.add(points(1), mark: "square") +/// plot.add(points(2), mark: "triangle") +/// plot.add(points(3), mark: "o") +/// plot.add(points(4), mark: "+") +/// plot.add(points(5), mark: "-") +/// plot.add(points(6), mark: "|") +/// plot.add(points(7), mark: "<>") +/// plot.add(points(8), mark: 5) // specify an integer to use a regular polygon. +/// +/// // Alternatively, specify custom function: +/// plot.add(points(9), mark: (pt, size, style) => { +/// let top = (to: pt, rel: (0, size)) +/// let bot = (to: pt, rel: (0, -size)) +/// let left = (to: pt, rel: (-size/2, 0)) +/// let right = (to: pt, rel: (size/2, 0)) +/// cetz.draw.line(top, left, bot, right, close: true, ..style) +/// }) +/// }) +/// ``` +/// +/// +/// - mark-size (float): Mark size in canvas units /// - data (array,function): Array of 2D data points (numeric) or a function /// of the form `x => y`, where `x` is a value in `domain` /// and `y` must be numeric or a 2D vector (for parametric functions). diff --git a/src/plot/mark.typ b/src/plot/mark.typ index 9450d21..c401138 100644 --- a/src/plot/mark.typ +++ b/src/plot/mark.typ @@ -31,6 +31,13 @@ draw.line(ll(pt), rr(pt), ..style) } else if mark == "|" { draw.line(tt(pt), bb(pt), ..style) + } else if mark == "diamond" or mark == "<>" { + draw.line(ll(pt), tt(pt), rr(pt), bb(pt), close: true, ..style) + } else if type(mark) == int and mark > 2 { + let pts = range(mark).map(i => (to: pt, rel: (90deg + 360deg * i / mark, size/2))) + draw.line(..pts, close: true, ..style) + } else if type(mark) == function { + mark(pt, size, style) } }