Skip to content

Instantly share code, notes, and snippets.

@masonicboom
Created April 29, 2018 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masonicboom/dafeb49b3c1d4c44998969ef6c2a2e05 to your computer and use it in GitHub Desktop.
Save masonicboom/dafeb49b3c1d4c44998969ef6c2a2e05 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(scales)
min <- 1
max <- 1000
f <- function(b) { sqrt(1 + b**2)/(1 + b) }
x <- seq(min, max, 0.01)
y <- 1 - f(x)
p <- qplot(x, y, geom='line', color="#FF4136")
p <- p + scale_y_continuous(labels = scales::percent, breaks=seq(0, .3, .025))
p <- p + ylab("1 - c/(a + b)") + xlab("b / a")
p <- p + theme(legend.position="none")
p <- p + scale_x_continuous(breaks=c(min, seq(100, max, 100)))
p <- p + ggtitle("Returns to Cutting Corners")
ggsave("cutcorners.png", p, width=6, height=5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment