Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # install
- install.packages('ggplot2')
- install.packages('readr')
- # load
- library(ggplot2)
- library(readr)
- # Plot
- ggplot(mtcars) +
- geom_point(aes(disp, mpg, size = hp))
- # Title
- ggplot(mtcars) +
- geom_point(aes(disp, mpg, size = hp)) +
- scale_size_continuous(name = "Horsepower")
- # Range
- ggplot(mtcars) +
- geom_point(aes(disp, mpg, size = hp)) +
- scale_size_continuous(range = c(3, 6))
- # Limits
- ggplot(mtcars) +
- geom_point(aes(disp, mpg, size = hp)) +
- scale_size_continuous(limits = c(0, 400))
- # Breaks
- ggplot(mtcars) +
- geom_point(aes(disp, mpg, size = hp)) +
- scale_size_continuous(breaks = c(100, 200, 300, 400))
- # Labels
- ggplot(mtcars) +
- geom_point(aes(disp, mpg, size = hp)) +
- scale_size_continuous(breaks = c(100, 200, 300, 400),
- labels = c("Hundred", "2 Hundred", "3 Hundred", "4 Hundred"))
- # Putting it all together
- ggplot(mtcars) +
- geom_point(aes(disp, mpg, size = hp)) +
- scale_size_continuous(name = "Horsepower", range = c(3, 6),
- limits = c(0, 400), breaks = c(100, 200, 300, 400),
- labels = c("Hundred", "2 Hundred", "3 Hundred", "4 Hundred"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement