【发布时间】:2021-01-15 03:35:31
【问题描述】:
我有一个名为TP_FP 的df,并希望使用ggplot2 基于Group 列创建一个背靠背(镜像)直方图。
`TP_FP`
Value Group
<dbl> <chr>
1 -0.00540 False positive
2 0.331 True positive
3 -1.11 False positive
4 1.4365 False positive
5 -0.586 True positive
6 1.26 True positive
7 0.5463 False positive
8 3.245 False positive
9 -0.950 False positive
10 10.4354 True positive
我尝试了以下方法:
ggplot(TP_FP, aes(x=x)) +
geom_histogram(aes(x=Value, y = -..density.., fill= Group == "False positive"),col="black", binwidth = 0.1) +
geom_histogram( aes(x=Value,y = ..density.., fill= Group =="True positive"),col="black", binwidth = 0.1) +
labs(x="R Ratio", y="Number of proteins") +
theme_bw() + theme(legend.position="right")
我希望得到一个像底部那样的合并直方图。
【问题讨论】: