我画了一个直方图,显示当分配不平衡的概率之和为50%、80%和90%时,我想添加垂直线( Histogram )。
我已经构建了直方图,但是我无法添加上面描述的垂直线。
pl <- ggplot() +
geom_line(data = data.frame(power1, abs(t-c)), aes(x = abs(t-c), y = power1, color = "power"), size = 1) +
scale_y_continuous(labels = percent_format(), sec.axis = sec_axis(~.*.3, labels = percent_format(), name = "Probability of allocation imbalance")) +
geom_point(data = data.frame(power1, abs(t-c)), aes(x = abs(t-c), y = power1)) +
geom_histogram(data = Simple_Rand_simulation, aes(x = Imbalance_all, y = ..density..*3), color = "blue",
binwidth = density(Simple_Rand_simulation$Imbalance_all)$bw) +
labs(y = "Probability of power", x = "Allocation imbalance", colour = "Parameter") +
theme(legend.position = c(0.8, 0.9))
pl当分配不平衡的概率之和为50%、80%和90%时,我预计会出现垂直线
发布于 2019-01-11 22:29:58
您可能只需要使用geom_vline()。如果您在.5、.8和point .9上需要它们,它将是:
pl +
geom_vline(xintercept = .5) +
geom_vline(xintercept = .8) +
geom_vline(xintercept = .9)当然,您可以根据累积概率的计算对这些值进行编码。
https://stackoverflow.com/questions/54148218
复制相似问题