I am trying to plot the plot the data of three constituents on the same plot using ggplot. Specifically, I am trying to get a stacked line/area plot that represents the data distribution. The three constituents each have 451 values, hence why I have put the runif value as 451.
The code I am using is:
library(dplyr)
library(ggplot2)
cdom <- t(as.matrix(read.csv("CDOM.csv")))
abcoef <- as.numeric(cdom[2,], cdom[3,], cdom[4,], times=3)
wavelength <- as.numeric(cdom[1,], each=3)
value <- runif(451, -1, 1)
data <- data.frame(abcoef,wavelength,value)
ggplot(data, aes(x=wavelength, y=value, fill=abcoef)) +
geom_area()
However, every time I try and run the code I get the code:
"Error in f(...) : Aesthetics can not vary with a ribbon"
I have tried multiple methods of trying to derive the plot, but every format is resulting in the same error message. Any help would be great!
cdom
is not available for anybody who wants to help you – Portunaas.numeric()
as if it isrep()
. Are you maybe missing somerep()
calls in there? – Inmeshggplot(data, aes(x=wavelength, y=value, fill=factor(abcoef))) + geom_area()
– Jammiejammin