Skip to content

Instantly share code, notes, and snippets.

@tbates
Created November 23, 2015 22:38
Show Gist options
  • Save tbates/f2e43a4d40a9fb527b1e to your computer and use it in GitHub Desktop.
Save tbates/f2e43a4d40a9fb527b1e to your computer and use it in GitHub Desktop.
plot miles per gallon on x axis, l/100km on the y
library(ggplot2)
library(scales)
gal_per_l = 0.219969
mi_per_km = 0.621371
l100km = seq(2, 13, by = .1)
l_per_km = l100km/100
l_per_mi = l_per_km/mi_per_km
gal_per_mi = l_per_mi * gal_per_l
mpg = 1/gal_per_mi
qplot(mpg, l100km, geom="line") +
scale_x_continuous(breaks = pretty_breaks(n = 10)) +
scale_y_continuous(breaks = pretty_breaks(n = 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment