I am trying to make a stacked line plot in ggplot2 with positive values stacked above the x-axis and negative values stacked separately below the x-axis. I have had success stacking each of the line types separately, but have not been able to have both on a single plot. I'm looking for some help on how I can do this, either by overlaying plots or doing something creative on a single plot.
My code below uses a simple ggplot with stacked geom_line plot. Half of the "Types" are positive values with respect to time and the other half of the "Types" are all negative values.
p <- ggplot(dataForm, aes(x=Time,y=Value,group=Type),colour=factor(Type))
p + geom_line(aes(fill = Type),position = "stack")
I have tried an alternative of specifying the positive and negative values separately without success:
p <- ggplot(dataForm, aes(x=Time,y=Value,group=Type),colour=factor(Type))
p + geom_line(data = data1,aes(fill = Type),position = "stack")
p + geom_line(data = data1,aes(fill = Type),position = "stack")
Any advice on how to do this is greatly appreciated. Thanks.