I would like to change the line size with a continuous variable. Now I used the geom_line with aesthetics size. For example:
x <- 1:100
y <- x * x
z <- abs(cos(x * pi / (max(x))))
df <- data.frame(x = x, y = y, z = z)
library(ggplot2)
ggplot(df, aes(x, y, size = z)) + geom_line()
But there are some spaces among segments (see figure below. Please zoom in to see the spaces). it seems ggplot2 uses rectangles to plot each segment.
I have increased the point number, but spaces till exist for bigger curvature.
My question is how to remove these spaces. I really appreciate it for any suggestions.