13
我看到很多关于如何自定义图例的问题,但我甚至无法获取图例来自定义。我希望有一个传说解释黑线是二次的,绿线是立方。ggplot2为几个stat_functions添加图例
library(ggplot2)
myfun1 <- function(x) x^2
myfun2 <- function(x) x^3
myplot <- ggplot(data = data.frame(x = 1:5, y= 1:5), aes(x=x, y=y)) +
stat_function(fun = myfun1, color="green") +
stat_function(fun = myfun2, color="black")
谢谢,kohske – 2012-04-10 17:18:26