私は20のファセットを持つ図形に線形回帰(実際には9つ)を当てようとしています。回帰に合うたびに(method = lmを使ってgeom_smoothを使うと)、それは20行、各面に1つずつフィットしますが、各ReefSpeciesの組み合わせごとに1つの行を20個のファセットすべてに渡します。ここでggplotの複数のファセットを使った1回の回帰
は私の図である。ここでは
は、私がこれまで持っているものである:コメントに基づいて
Biomass <- c(20, 10, 5, 4, 5, 7, 8, 22, 13, 13, 15, 18, 2, 5, 7, 10)
Season <- c("Winter", "Spring", "Summer", "Fall")
Year <- c("1", "2", "3", "4")
ReefSpecies <- c("Admiral Ma", "Jaap Mf", "Grecian Ma", "Alligator Mf", "Jaap Mf", "Grecian Ma", "Alligator Mf", "Admiral Ma", "Grecian Ma", "Alligator Mf", "Admiral Ma", "Jaap Mf", "Alligator Mf", "Admiral Ma", "Jaap Mf","Grecian Ma")
Seasonal <- data.frame(Biomass, Season, Year, ReefSpecies)
testp <- ggplot(data = Seasonal, aes(x = Season, y = Biomass, group = ReefSpecies, fill = ReefSpecies, colour = ReefSpecies))
testp <- testp + geom_point(stat = "identity", position="identity", inherit.aes = TRUE)
testp <- testp + facet_grid(. ~ Year, scales="fixed")
testp <- testp + theme(axis.text.x = element_text(angle = 90))
testp <- testp + theme(panel.margin.x = unit(0, "lines"))
testp <- testp + theme(legend.position = "top")
testp
あなたの質問は、再現してください。 – Andrie
この問題では、問題を再現できるように、少しのデータを提供してください。 – lmo
ggplotGrobのものとすべてのテーマ要素はあなたの質問とは関係がなく、ポストを目につけにくくするだけです。 'geom_point()'の中のものも不要です。 私は、回帰(stat_smoothなんか?)に合うようにあなたが使っている線があれば、その層の中に 'group'という美学を特別に設定することを提案します。初期の 'ggplot()'呼び出しでは、別途指定しない限り、他のすべてのレイヤーによって継承されるグループ化と色付けの美しさをどのように設定しているかに注意してください。 '+ geom_smooth(method =" lm "、aes(group = 1))のようなものを追加することができます。 – Matt74