Powered by AppSignal & Oban Pro

Stacked axes: guide_axis_stack

notebooks/guide_axis_stack.livemd

Stacked axes: guide_axis_stack

Mix.install([
  {:giggly, path: Path.join(__DIR__, "..")},
  {:kino, "~> 0.19"}
  ])

About this notebook

This notebook follows the examples on ggplot2's reference page for guide_axis_stack(), in the order the page gives them. Each example shows ggplot2's code first and then Giggly's. An example Giggly cannot draw yet keeps its ggplot2 code and names what it is waiting for, so the page is also a list of what remains.

guide_axis_stack() draws several position guides for one axis, one beyond another: the first closest to the panel, the rest outward in the order given. Each is given as a guide's name, such as "axis", or as a call to a guide function. Giggly has no axis guides yet (guide_axis()); Giggly.Plot.theme/2 styles an axis's line, ticks and labels.

A normal axis and a capped one

# A standard plot
p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  theme(axis.line = element_line())

# A normal axis first, then a capped axis
p + guides(x = guide_axis_stack("axis", guide_axis(cap = "both")))

Not in Giggly yet: guide_axis_stack(), and guide_axis() with its cap option, which stops the axis line at the outermost breaks.