首页 > 解决方案 > ggplot2 计算 x_intercept

问题描述

我正在使用 ggplot2 绘制两个数据系列,如下所示,一个 Dm1 为红色,另一个 Dm2 为绿色。

帮助 x_intercept

  p<-ggplot() +
  geom_line(data= Dm1, aes(x = x, y = y , color = "Dm1")) +
  geom_line(data= Dm2, aes(x = x, y = y, color = "Dm2")) +
  scale_x_log10() +
  scale_y_log10() +
  scale_colour_manual("", 
                      breaks = c("Dm1", "Dm2"),
                      values = c("red", "green")) 


p+labs(x = "x in log scale", y="y in log scale", title = "help")+ 
  theme(legend.position = c(0.8, 0.8)) + 
  geom_hline(yintercept = 0.006262418)

我在绿线上的位置 (y) = (0.006262418) 处画了一条线,现在我想计算它在 x 的哪个位置与红线 (x_intercept) 相交。我该怎么做?

标签: rggplot2

解决方案


推荐阅读