1

我绘制了一个直方图,显示了直方图 当分配不平衡的概率总和为 50%、80% 和 90% 时,我想添加垂直线。

我已经构建了直方图,但无法添加上述垂直线。

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% 时,我期望垂直线

4

1 回答 1

0

您可能只需要使用geom_vline(). 如果您在 0.5、0.8 和 0.9 处需要它们,则为:

pl + 
  geom_vline(xintercept = .5) + 
  geom_vline(xintercept = .8) + 
  geom_vline(xintercept = .9)

但当然,您可以根据累积概率的计算对这些值进行编码。

于 2019-01-11T14:29:58.293 回答