ggplot(diamonds, aes(carat, price)) +
geom_point() +
geom_smooth()
ggplot(diamonds, aes(carat, price)) +
geom_point(alpha = .01) +
geom_smooth(se = FALSE) +
scale_y_continuous(labels = scales::dollar) +
labs(title = "Exponential relationship between carat size and price",
subtitle = "Sample of 54,000 diamonds",
x = "Carat size",
y = "Price") +
theme_minimal()
mpg
mpg
## # A tibble: 234 x 11
## manufacturer model displ year cyl trans drv cty hwy
## <chr> <chr> <dbl> <int> <int> <chr> <chr> <int> <int>
## 1 audi a4 1.8 1999 4 auto(l5) f 18 29
## 2 audi a4 1.8 1999 4 manual(m5) f 21 29
## 3 audi a4 2.0 2008 4 manual(m6) f 20 31
## 4 audi a4 2.0 2008 4 auto(av) f 21 30
## 5 audi a4 2.8 1999 6 auto(l5) f 16 26
## 6 audi a4 2.8 1999 6 manual(m5) f 18 26
## 7 audi a4 3.1 2008 6 auto(av) f 18 27
## 8 audi a4 quattro 1.8 1999 4 manual(m5) 4 18 26
## 9 audi a4 quattro 1.8 1999 4 auto(l5) 4 16 25
## 10 audi a4 quattro 2.0 2008 4 manual(m6) 4 20 28
## # ... with 224 more rows, and 2 more variables: fl <chr>, class <chr>
ggplot(mpg, aes(hwy)) +
geom_histogram()
geom_rug()
ggplot(mpg, aes(hwy)) +
geom_histogram() +
geom_rug()
ggplot(mpg, aes(hwy)) +
geom_histogram(bins = 50) +
geom_rug()
ggplot(mpg, aes(hwy)) +
geom_histogram(bins = 10) +
geom_rug()
ggplot(mpg, aes(class)) +
geom_bar()
ggplot(mpg, aes(class, hwy)) +
geom_boxplot()
ggplot(mpg, aes(displ, hwy)) +
geom_point()
ggplot(mpg, aes(hwy)) +
geom_histogram() +
facet_wrap(~ drv)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
facet_wrap(~ drv)
ggplot(mpg, aes(displ, hwy, color = class)) +
geom_point()
ggplot(mpg, aes(displ, hwy, color = class, size = cyl)) +
geom_point()
ggplot(mpg, aes(displ, hwy, shape = class)) +
geom_point()
## Warning: The shape palette can deal with a maximum of 6 discrete values
## because more than 6 becomes difficult to discriminate; you have 7.
## Consider specifying shapes manually if you must have them.
## Warning: Removed 62 rows containing missing values (geom_point).