How to access calculated values of geom_curve in ggplot2 (R)?

你离开我真会死。 提交于 2019-12-22 09:09:56

问题


I am looking for the calculated values of ggplot2 when applying geom_curve.

Herefore, a little reproducible example:

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

This plots a red curve between the two points of my data.frame. I am interested in the calculated values for plotting the arc, done by geom_curve. How can I access them?

I was looking at ggplot_build(plot) but did not succeed. E.g. in ggplot_build(plot)$layout$finish_data is function stored but I don't know how to access it.

Or in ggplot_build(plot)$data are just the definitions of the curved stored but I think the values have to be somewhere in ggplot_build.

I would like to get all the calulcated points of this geom_curve or store the applied function in my global environment.

来源:https://stackoverflow.com/questions/45734457/how-to-access-calculated-values-of-geom-curve-in-ggplot2-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!