Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified manual.pdf
Binary file not shown.
31 changes: 29 additions & 2 deletions src/plot/line.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
7 changes: 7 additions & 0 deletions src/plot/mark.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Loading