I was hoping someone might be able to help. I am still getting to grips with R and I am quite new to ggplot2.
My problem:
I am trying to make a stacked area plot. I have formatted my data frame so that it is in long format. My columns are Date, Category (filter.size) and value (chl.average).
e.g: data frame example
The issue I am having is that when I try and plot this, where Chlstacked is my data.frame):
stkchl <- ggplot(Chlstacked, aes(x=Date, y=chl.average,
fill=filter.size)) + geom_area()
stkchl
the axis and background layer plots but not the actual stack, although it recognises the categories in a legend with colours.
I have tried and alternate method:
stkchl <- ggplot(Chlstacked, aes(x=Date, y=chl.average))
stkchl
stkchl + geom_area(aes(colour = chl.average, fill= chl.average),
position = 'stack')
Which gives: Error in f(...) : Aesthetics can not vary with a ribbon
My thought is that perhaps as the Dates, which I would want on the x-axis (as it is time series), are repeated for each category (>20, <20>5, <5>GFF) they are not unique so maybe doing something - altough I am stumped as to what - to cause error.Or perhaps something simple that I am doing wrong within my coding?
Any help would be appreciated - thanks