This document is adapted from the Histograms section of the Altair Example Gallery.

Our first step is to set up our environment:

library("altair")
library("tibble")
library("tidyr")
library("jsonlite")

vega_data <- import_vega_data()

Histogram with a Global Mean Overlay

Altair example

Chart

Layered Histogram

Altair example

Chart

Trellis Histogram

Altair example

This example is originally from Vega-Lite.

Chart