私は 'ggplot2'を使ってスタックバープロットを生成した次のデータセットを持っています。RベースプロットのR ggplot2バー相当物
データ - >
X1 X2 X3
1 1 10 13.53
2 1 10 16.81
3 2 10 16.24
4 2 10 17.42
5 1 10 15.20
6 1 10 29.40
7 1 10 45.30
8 1 10 14.00
9 1 10 23.50
10 2 10 12.30
ggplot2コード--->
ggplot(data=dat1, aes(x=X2, y=X3, fill=X1,width=0.5)) +
geom_bar(stat="identity") + coord_flip() +
theme(legend.position="bottom",legend.direction="horizontal",legend.text=element_text(size=12),
plot.margin=unit(c(0.1,1,0.25,1), "cm"),
panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank())+
guides(fill=guide_legend(nrow=1,byrow=TRUE)) +
scale_x_continuous(breaks = 10)+
scale_y_continuous(breaks=c(seq(0,sum(dat1$X3),50),sum(dat1$X3)),expand = c(0,0))+
labs(fill="")
私は今(barplotを使用してRベースプロットに変換したい)Rの機能するように、私はそれをどこか別の場所で使うことができます。私はスタックバープロットを私は単一の列を使用して2つのグループを使用してスタックする必要があるベースバープロット関数を使用して生成することができません。
ありがとうございました。
ggplot barplotを別の場所で使用できないのはなぜですか? – user3640617
@ user3640617:結合に問題がある別のRプロット(時系列)と結合する必要があります。代替案として、私はRベースプロットで両方を作りたがっていました。 –