2017-08-24 74 views
-1

我试图用ggplot2在同一个窗口(大约12)中绘制多个图形,并使用相同的x轴。我想使用适合该图的y轴范围,而不是对所有图使用固定的y轴。有关如何实现它的任何建议?如何在R中一次绘制多个图时更改y轴范围?

目前代码

tube_no <- c(1,2,1,2,1,2,1,2) 
concentration <- c(1000,500,2,3,45,55,100,90) 
dye <- c("blue","blue","red","red","white","white","green","green") 
dat <- data.frame(tube_no,concentration,dye) 


library(ggplot2) 
ggplot(data = dat, aes(x = tube_no, y = concentration)) + geom_point() + facet_wrap(~dye) 
+1

或者这样:[GGPLOT2,facet_grid,自由尺度?](https://stackoverflow.com/questions/3685285/ggplot2-facet-grid-free-scales) – Masoud

+1

或:为ggplot2中的每个方面设置不同的轴限制,不使用scales =“free”](https://stackoverflow.com/questions/39229455/setting-different-axis-limits-for-each-facet-in-ggplot2-not-使用尺度免费) – Masoud

回答

1

可以使用秤= “免费” 的说法来facet_wrap

ggplot(data = dat, aes(x = tube_no, y = concentration)) + geom_point() + 
     facet_wrap(~dye, scales="free") 

enter image description here