There are multiple solutions to create a stacked bar plot in R, but how to draw a stacked line plot?
A stacked line plot can be created with the ggplot2
package.
Some example data:
set.seed(11)
df <- data.frame(a = rlnorm(30), b = 1:10, c = rep(LETTERS[1:3], each = 10))
The function for this kind of plot is geom_area
:
library(ggplot2)
ggplot(df, aes(x = b, y = a, fill = c)) + geom_area(position = 'stack')