我想知道是否有一種方法可以為 ggplot 中的并排條形圖定義每組的出現順序。我的資料集是
> df
V1 V2 V3
1 真關節 0.18
2 真實個體 0.82
3 估計聯合 0.37
4 估計個人 0.63
下面這行代碼
library(ggplot2)
ggplot(df, aes(x = V2, y = V3, fill = V1))
geom_col(position = position_dodge2())
scale_fill_manual(values=c("steelblue","coral2"))
guides(fill = guide_legend(reverse = T))
scale_x_discrete(limits = unique(df$V2))
theme(legend.title = element_blank())
xlab("Structure") ylab("Variance")
ggtitle("Variance Explained by Joint and Individual structure")
給我這個

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/389575.html
