如何在ggplot2(R)中访问geom_curve的计算值?

时间:2017-08-17 11:55:11

标签: r ggplot2 bezier curve

我在申请geom_curve时正在寻找ggplot2的计算值。

因此,一个可重复的例子:

require(ggplot2)
df <- data.frame(x=c(0,2), y=c(5,5))

plot <- ggplot() + 
geom_curve(data = df, aes(x = df[1,"x"], y = df[1,"y"], xend = df[2,"x"], yend = df[2,"y"]), 
         color = "red", linetype = 3, curvature = 0.4, size = 2)
plot

这绘制了我的data.frame的两个点之间的红色曲线。我对绘制弧的计算值感兴趣,由geom_curve完成。我该如何访问它们?

我在看ggplot_build(plot)但没有成功。例如。在ggplot_build(plot)$layout$finish_data中存储了函数,但我不知道如何访问它。

或者ggplot_build(plot)$data只是存储曲线的定义,但我认为值必须在ggplot_build的某处。

我想得到这个geom_curve的所有被计算的点,或者将应用的函数存储在我的全局环境中。

0 个答案:

没有答案