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

Our first step is to set up our environment:

library("altair")
library("tibble")
library("jsonlite")
library("dplyr")
library("readr")

vega_data <- import_vega_data()

Filled step chart

Altair example

Chart

Line chart with Confidence Interval Band

Altair example

This example shows how to make a line chart with a bootstrapped 95% confidence interval band.

Chart

Line Chart with Layered Aggregates

Altair example

This example shows how to make a multi series line chart of the daily closing stock prices for AAPL, AMZN, GOOG, IBM, and MSFT between 2000 and 2010, along with a layered rule showing the average values.

Chart

Line Chart with Percent axis

Altair example

Chart

Line Chart with Points

Altair example

Chart

Line Chart with Varying Size

Altair example

Chart

Multi Series Line Chart

Altair example

Chart

A difference from the Python example is that you have to make sure that you declare that the date variable is of type "temporal"

Slope Graph

Altair example

Chart

Step Chart

Altair example

This example shows Google’s stock price over time. This uses the step-after interpolation scheme. The full list of interpolation options includes linear, linear-closed, step, step-before, step-after, basis, basis-open, basis-closed, cardinal, cardinal-open, cardinal-closed, bundle, and monotone.

Chart