element-line

Line element: colour and thickness.

Pass the result to theme under keys like panel-grid or axis-line.

Usage

element-line(
  colour: none,
  thickness: none,
)

Parameters

Parameter Default Description
colour none Line colour, or none to inherit.
thickness none Line thickness (a Typst length), or none.

Returns

Element dictionary consumed by theme.

Examples

Recolour the panel grid via theme.

#let d = range(0, 10).map(i => (x: i, y: i * 0.5))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-point(size: 2pt),),
  theme: theme(panel-grid: element-line(colour: rgb("#d9cfbf"))),
  width: 10cm,
  height: 6cm,
)

Scatter plot of y against x with the panel gridlines recoloured pale stone via element-line on the panel-grid surface.

Scatter plot of y against x with the panel gridlines recoloured pale stone via element-line on the panel-grid surface.

Strengthen the axis line by setting both colour and thickness.

#let d = range(0, 10).map(i => (x: i, y: i * 0.5))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-point(size: 2pt),),
  theme: theme(axis-line: element-line(
    colour: rgb("#cc0000"),
    thickness: 1pt,
  )),
  width: 10cm,
  height: 6cm,
)

Scatter plot of y against x with axis lines drawn 1pt thick in red via element-line on the axis-line surface.

Scatter plot of y against x with axis lines drawn 1pt thick in red via element-line on the axis-line surface.

See also

theme, element-text, element-rect, element-blank.

Back to top