【发布时间】:2017-10-08 00:13:49
【问题描述】:
我试图找到如何在 ggplot 中对由函数定义的两行之间的区域进行着色的可能性。我找到了一些使用 geom_area 或 geom_ribbon 的解决方案,但在这两种情况下,您都需要一个定义 ymin 和 ymax 的数据库。还有其他可能吗? ymin 和 ymax 的定义方式也与线条相同?
这是我的示例:
myplot <- ggplot(data.frame(x=c(0, 100)), aes(x=x)) +
stat_function(fun= function(x)20*sqrt(x), geom="line", colour= "black", size= 1) +
stat_function(fun= function(x)50*sqrt(x), geom="line", colour= "black", size= 1)
myplot
提前感谢您的帮助。
【问题讨论】:
标签: r function ggplot2 fill between