Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. df = data.frame("x" = rnorm(6),
  2. "y" = rnorm(6),
  3. "class" = letters[1:6] %>% toupper)
  4.  
  5. colors = c("#FF0000", "#0000FF")
  6. shapes = c(16, 17, 18)
  7. class_form = expand.grid("color" = colors,
  8. "shape" = shapes)
  9. rownames(class_form) = letters[1:6] %>% toupper
  10. print(class_form)
  11.  
  12. gg = ggplot(data = df,
  13. mapping = aes(x = x,
  14. y = y,
  15. fill = class,
  16. color = class,
  17. shape = class))
  18. gg = gg + geom_point()
  19. gg = gg + scale_fill_manual (values = class_form[, "color"])
  20. gg = gg + scale_color_manual(values = class_form[, "color"])
  21. gg = gg + scale_shape_manual(values = class_form[, "shape"])
  22. gg %>% print
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement