Trouble with ggplot in R - "Error in f(...) : Aesthetics can not vary with a ribbon"
Asked Answered
T

0

2

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!

Tasman answered 28/2, 2019 at 0:48 Comment(3)
Please share a portion of your data, as cdom is not available for anybody who wants to help youPortuna
I think you've got some syntax errors.... you're giving arguments to as.numeric() as if it is rep(). Are you maybe missing some rep() calls in there?Inmesh
ggplot(data, aes(x=wavelength, y=value, fill=factor(abcoef))) + geom_area()Jammiejammin

© 2022 - 2024 — McMap. All rights reserved.