我想將下面顯示的資料繪制為分組的 ba??r_plot。
我試過了position = "dodge",position = "dodge2"但是沒有用。Ι 也試過position = position_dodge()
如果我使用geom_bar而不是geom_col洗掉它有點作業y=overlap_percent:
p3 <- ggplot(data = comp_coors, aes(x = species_code, fill = mirna_form))
geom_bar(position = "dodge2") theme_classic()
p3

但我希望 y_axis 具有overlap_percent.
另一種以堆積條形圖結尾的嘗試是:
p2 <- ggplot(data = comp_coors, aes(x = species_code, y = overlap_percent, fill = mirna_form))
geom_bar(stat = "identity") theme_classic()
p2

最后通過 using geom_col,它回傳了這個它沒有意義,至少對我來說:
p4 <- ggplot(data = comp_coors, aes(x = species_code, y = overlap_percent, fill = mirna_form))
geom_col(position = "dodge") theme_classic()
p4

我要繪制的資料:
comp_coors <- data.table( species = c("aae","cel", "dme","hsa", "mdo"),
mirna_form = c("mature", "precursor"),
overlap_percent = c(100.0, 100.0, 88.0, 95.5, 91.7, 100.0, 96.6, 98.4),
overlapping_attribute = c("ID=MIMAT0014285;Alias=MIMAT0014285", "ID=MI0000043;Alias=MI0000043;Name=cel-mir-72", "ID=MIMAT0000401;Alias=MIMAT0000401;Name=dme-miR-", "ID=MI0000791;Alias=MI0000791;Name=hsa-mir-383", "ID=MI0005331;Alias=MI0005331;Name=mdo-let-7g")
)
uj5u.com熱心網友回復:
嘗試使用species作為一個因素并stat = "identity"像這樣添加:
ggplot(data = comp_coors, aes(x = factor(species), y = overlap_percent, fill = mirna_form))
geom_bar(position = "dodge", stat = "identity") theme_classic() labs(x = "Species", y = "Overlap percent")
輸出:

overlap_percenty 軸右側的分組條形圖。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/477224.html
上一篇:Romove例外值來自ggplot2中的stat_summary
下一篇:R中的分組圖
