Guest User

Untitled

a guest
Oct 22nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. growth.plot<-function(data,x,y,fac){
  2. gp <- ggplot(data = data,aes(x = x, y = y))
  3. gp <- gp + geom_point() + facet_wrap(~ fac)
  4. return(gp)
  5. }
  6.  
  7. growth.plot(data=mydata, x=x.var, y=y.var,fac= fac.var)
  8.  
  9. gp1 <- ggplot(data = mydata,aes(x = x.var), y = y.var))
  10. gp1+ geom_point()+ facet_wrap(~ fac.var) # this works
  11.  
  12. library(ggplot2)
  13.  
  14. make_plot = function(data, x, y, fac) {
  15. p = ggplot(data, aes_string(x=x, y=y, colour=fac)) +
  16. geom_point(size=3) +
  17. facet_wrap(as.formula(paste("~", fac)))
  18. return(p)
  19. }
  20.  
  21. p = make_plot(iris, x="Sepal.Length", y="Petal.Length", fac="Species")
  22.  
  23. ggsave("iris_plot.png", plot=p, height=4, width=8, dpi=120)
Add Comment
Please, Sign In to add comment