scale-shape

Discrete shape scale: maps levels to marker-shape keywords.

Pass a custom array of keywords via palette to override the default shape set.

Usage

scale-shape(
  name: none,
  palette: auto,
  limits: none,
  labels: auto,
)

Parameters

Parameter Default Description
name none Legend title. Overrides any name set via labs when both are present.
palette auto Array of shape keywords, or auto for the library default.
limits none Array of level names controlling order and inclusion, or none.
labels auto Array of legend labels aligned with limits, or auto.

Returns

Scale object consumed by plot.

Examples

Default shape palette mapping three categories to distinct markers.

#let d = (
  (x: 1, y: 2, sp: "a"),
  (x: 2, y: 4, sp: "b"),
  (x: 3, y: 3, sp: "c"),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", shape: "sp"),
  layers: (geom-point(size: 3pt),),
  scales: (scale-shape(),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of three points along x against y where the sp column drives the marker glyph through the default discrete shape palette.

Scatter chart of three points along x against y where the sp column drives the marker glyph through the default discrete shape palette.

Pair shape and fill mappings with the same column to reinforce the categorical encoding.

#let d = (
  (x: 1, y: 2, sp: "a"),
  (x: 2, y: 4, sp: "b"),
  (x: 3, y: 3, sp: "c"),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", shape: "sp", fill: "sp"),
  layers: (geom-point(size: 4pt),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of three points where sp drives both marker glyph and fill colour, reinforcing the categorical encoding through redundant channels.

Scatter chart of three points where sp drives both marker glyph and fill colour, reinforcing the categorical encoding through redundant channels.

See also

scale-shape-manual, geom-point.

Back to top