Setup
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.0 ✓ purrr 0.3.4
## ✓ tibble 3.0.5 ✓ dplyr 1.0.3
## ✓ tidyr 1.0.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(ggthemes)
Basic Graph
p = mpg %>% ggplot(aes(x = cty,y = hwy)) +
geom_point(color = 'green', size = 2) +
geom_jitter(size = .5) +
geom_smooth() +
geom_smooth(method = "lm",color = "red") +
labs(x = "City MPG", y = "Highway MPG")
p + ggtitle("Highway vs City MPG\nBasic")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'

Use the Theme “economist”
p + theme_economist() +
ggtitle("Highway vs City MPG\neconomist")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
