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