Position adjustments: layer_positions
Mix.install([
{:giggly, path: Path.join(__DIR__, "..")},
{:kino, "~> 0.19"}
])
About this notebook
ggplot2's reference page for
layer_positions has no
examples, so this notebook says only what the page describes and where Giggly stands.
A layer's position adjusts where its marks sit, mostly to keep them from overlapping: dodging sets
them side by side, stacking piles them up, filling scales each pile to a proportion, jittering adds
random noise and nudging offsets them by a fixed distance. ggplot2 takes a layer's position from a
geom's default, as a string (position = "jitter"), as a position_*() function, which also
carries its options, or through layer(); for many layers it is position_identity(), which leaves
them where they are. Giggly has stacking and dodging, for bars and histograms:
Giggly.Plot.geom_bar/3, Giggly.Plot.geom_col/3 and Giggly.Plot.geom_histogram/3 stack by
default, or dodge with position: :dodge, as position = "dodge" does, or with position: :dodge2
or Giggly.Plot.position_dodge2/1, as position_dodge2() does, which Giggly.Plot.geom_boxplot/3
dodges its boxes with by default; stacking, for areas and densities: Giggly.Plot.geom_area/3
stacks by default, and Giggly.Plot.geom_density/3 with position: :stack; and nudging, for text:
Giggly.Plot.geom_text/3 nudges every label by its nudge_x: and nudge_y: options, as ggplot2's
geom_text() does. Not in Giggly yet: position_fill(), position_jitter(),
position_jitterdodge() and position_nudge(), the options of position_stack() and
position_dodge(), position_dodge2()'s width option, and layer().