Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. # install
  2. install.packages('ggplot2')
  3. install.packages('readr')
  4.  
  5. # load
  6. library(ggplot2)
  7. library(readr)
  8.  
  9. # Plot
  10. ggplot(mtcars) +
  11. geom_point(aes(disp, mpg, size = hp))
  12.  
  13. # Title
  14. ggplot(mtcars) +
  15. geom_point(aes(disp, mpg, size = hp)) +
  16. scale_size_continuous(name = "Horsepower")
  17.  
  18. # Range
  19. ggplot(mtcars) +
  20. geom_point(aes(disp, mpg, size = hp)) +
  21. scale_size_continuous(range = c(3, 6))
  22.  
  23. # Limits
  24. ggplot(mtcars) +
  25. geom_point(aes(disp, mpg, size = hp)) +
  26. scale_size_continuous(limits = c(0, 400))
  27.  
  28. # Breaks
  29. ggplot(mtcars) +
  30. geom_point(aes(disp, mpg, size = hp)) +
  31. scale_size_continuous(breaks = c(100, 200, 300, 400))
  32.  
  33. # Labels
  34. ggplot(mtcars) +
  35. geom_point(aes(disp, mpg, size = hp)) +
  36. scale_size_continuous(breaks = c(100, 200, 300, 400),
  37. labels = c("Hundred", "2 Hundred", "3 Hundred", "4 Hundred"))
  38.  
  39. # Putting it all together
  40. ggplot(mtcars) +
  41. geom_point(aes(disp, mpg, size = hp)) +
  42. scale_size_continuous(name = "Horsepower", range = c(3, 6),
  43. limits = c(0, 400), breaks = c(100, 200, 300, 400),
  44. labels = c("Hundred", "2 Hundred", "3 Hundred", "4 Hundred"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement