我有這樣的代碼:面值(mfrow)中的R爲ggplot
plotfn= function(u) {
flt = filter(d, utensil ==u)
ggplot(flt,aes(x=p)) + geom_histogram(binwidth = 0.5, position= position_dodge(0.5), color="black",fill="cadetblue4")+ ggtitle("Histogram of P")+labs(x="P", y="Number of Observations")
}
lapply(unique(d$utensil),plotfn)
我試圖做一個par(mfrow= c(3,3))
讓所有9個地塊中1個屏幕,但它不工作。我必須使用ggplot。
有用的:http://www.cookbook-r.com/Graphs/(見「Facets」一章) –
此外,這個問題可能會有所幫助:http://stackoverflow.com/questions/5226807/multiplegraphics -in-one-canvas-using-ggplot2 – Stedy
爲什麼不使用'facet_grid'? Ggplot系統旨在避免這種混亂。對於兩種不同類型的情節,你可能會想'grid.arrange',但不是所有同類型的9。 –