Continue my question here: Variable line size using ggplot2
I can create a figure with these codes.
x <- 1:100
y <- x * x
z <- abs(cos(x * pi / (max(x))))
df <- data.frame(x = x, y = y, z = z)
library(ggplot2)
mult <- 200
ggplot(df, aes(x, y)) + geom_line() + geom_ribbon(aes(ymin=y-mult*z, ymax=y+mult*z))
But my question now is how to create a legend to reflect the size of line. For example, legend in this figure
ggplot(df, aes(x, y, size = z)) + geom_line()
Is there any way to and a legend from scratch which doesn't exist in the aes?
Thanks for any suggestions.