Reputation: 4477
I thought this was a problem with the ordering of how I was placing each aestetic. Here is the relevant code.
Sort of like a normal distribution. Going to melt it down and plot each distribution.
df <- as.data.frame(r_data_frame)
names(df) <- c('Length','Unique','Donor Unique','All')
library(ggplot2)
library(reshape2)
ndf <- melt(df,id.vars='Length')
print(ndf)
graph <- ggplot(data=ndf) + geom_area(aes(Length,value,fill=variable)) +
theme_bw()+
xlim(1,42)+
geom_hline(yintercept=2369802) +
geom_hline(yintercept=2469225,color='red')+
geom_vline(xintercept=15)
plot(graph)
The melted data frame is probably better found in this gist
Here is the output
The problem I'm having is that the shaded areas don't seem to be plotted correctly. I plotted the horizontal lines for both "Donor Unique" and "Unique" of where they should be according to the data frame. "Unique" is right as it is right at its y value. However "Donor Unique" is way to high. They should barely overlap. If you look at the values What in the world is going on? Should I be using something else besides geom_area?
Upvotes: 0
Views: 514
Reputation: 59355
You need to use position="dodge"
in the call to geom_area(...)
.
Many of the geom_*
functions in ggplot
, including geom_area(...)
, geom_histogram(...)
, and geom_bar(...)
, have a position parameter. The default is (usually...) "stacked", which creates geometries that are additive. To display the geometries with independent y-values, use position="dodge".
Upvotes: 1