2016-11-18 11 views
0

私の再現可能な例に従えば、35のチャートのリストが得られます.4つのグループでそれらを表示したいと思います。私は前にmfrowを使用しましたが、今はグラフを表示するコマンドを実行します全画面が単一のグラフで上書きされます。手伝ってくれますか ?チャートパネルにリストを追加表示する

library(tidyverse) 
x<-split(diamonds, with(diamonds, interaction(cut,color)), drop = TRUE) 

graphs<-list() 
for (i in 1:length(x)) 
    local({ 
    i<-i 
    chart<-print(ggplot(x[[i]],aes(x=clarity,fill=clarity))+ 
        geom_bar()) 

    graphs[[i]]<<-chart 
    i=i+1 
    print(i) 
    }) 

par(mfrow=c(2,2)) 
graphs[[1]] 
graphs[[2]] 
graphs[[3]] 
graphs[[4]] 
+1

'grid'パッケージ、' gridExtra'または 'cowplot'を参照してください –

答えて

1

これはggplotファセットと一度に私はscales = "free_y"を使用し、これらは非常に混雑になったのでtheme()でX-ラベルを削除

ggplot(diamonds,aes(x=clarity,fill=clarity)) + geom_bar() + 
    facet_grid(cut~color,scales = "free_y") + 
     theme(axis.title.x=element_blank(), axis.text.x=element_blank())  

注可能です。

+1

あなたは' scales = "free_y" 'を意味しましたか? –

+0

はい、私は修正した "free_y"だったはずです。ありがとう。 – Martin

関連する問題