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

Our first step is to set up our environment:

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

vega_data <- import_vega_data()

Binned Scatterplot

Altair example

Chart

Brushing Scatter Plot to show data on a table

Altair example

Chart

Bubble Plot

Altair example

Chart

Connected Scatterplot (Lines with Custom Paths)

Altair example

This example shows how layering can be used to build a plot. This dataset tracks miles driven per capita along with gas prices annually from 1956 to 2010. It is based on the May 2, 2010 New York Times article ‘Driving Shifts Into Reverse’. See this reference.

Chart

Dot Dash Plot

Altair example

This example shows how to make a dot-dash plot presented in Edward Tufte’s book Visual Display of Quantitative Information on page 133. This example is based on g3o2’s block.

Chart

Multifeature Scatter Plot

Altair example

Chart

Polynomial Fit Plot

Altair example

Chart

Scatter Matrix

Altair example

Chart

Scatter Plot with Href

Altair example

Chart

Scatter Plot with Rolling Mean

Altair example

Chart