2012-02-20 71 views
8

我可以創造一個多面的情節像這樣,有三個地塊堆疊垂直如何將分面標籤移動到圖形頂部?

ggplot(iris, aes(Petal.Length)) + stat_bin() + facet_grid(Species ~ .) 

是否有可能將標籤移動到每個圖的頂部,好像他們是,如果我做水平與facet_grid(. ~ Species)堆碼?

我想要這個的原因是我的地塊是很長的時間序列圖,所以我想要每個地塊的全部寬度,但是每個地塊的標籤(其本質上用作解釋標題的標題)太長適合情節右側的小標籤區域。

回答

10

是。使用facet_wrap代替facet_grid並確保還要指定參數ncol=1

ggplot(iris, aes(Petal.Length)) + stat_bin() + facet_wrap(~Species, ncol=1) 

enter image description here

+0

非常好,謝謝。 – 2012-02-20 20:32:32

4

試試這個:

ggplot(iris, aes(Petal.Length)) + stat_bin() + facet_wrap(~Species,nrow = 3) 

enter image description here

+0

快............ – Andrie 2012-02-20 19:52:03

+1

@Andrie至少我們做了一個_little_不同:當你設置'ncol = 1'時,我設置了'nrow = 3'! – joran 2012-02-20 19:54:05

+0

哇,不知道。漂亮漂亮+1 – 2012-02-20 20:16:31

相關問題