position-identity

Identity position adjustment: no offset applied to any row.

Typically set on a layer as position: "identity" rather than constructed directly; the constructor exists for symmetry with the other positions.

Usage

position-identity()

Returns

Position dictionary with name: "identity", consumed by plot.

Examples

Explicit identity position on a scatter, equivalent to the default behaviour of most geoms.

#let d = (
  (x: 1, y: 2),
  (x: 2, y: 4),
  (x: 3, y: 3),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-point(size: 3pt, position: "identity"),),
  width: 10cm,
  height: 6cm,
)

Scatter chart with x on the x-axis and y on the y-axis; three points drawn at their mapped coordinates with no positional adjustment.

Scatter chart with x on the x-axis and y on the y-axis; three points drawn at their mapped coordinates with no positional adjustment.

Use identity on geom-col when you have pre-computed bar heights you want drawn unchanged, even if a fill mapping is present.

#let d = (
  (q: "Q1", grp: "a", y: 3),
  (q: "Q1", grp: "b", y: 5),
  (q: "Q2", grp: "a", y: 4),
  (q: "Q2", grp: "b", y: 2),
)
#plot(
  data: d,
  mapping: aes(x: "q", y: "y", fill: "grp"),
  layers: (geom-col(position: "identity", alpha: 0.6),),
  width: 10cm,
  height: 6cm,
)

Overlapping bar chart with quarters on the x-axis and y on the y-axis; two semi-transparent coloured bars per quarter sit at the same base instead of stacking.

Overlapping bar chart with quarters on the x-axis and y on the y-axis; two semi-transparent coloured bars per quarter sit at the same base instead of stacking.

See also

position-stack, position-dodge, position-fill.

Back to top