I am trying to plot a stacked bar graph with mean values from multiple repeats, also showing the range of the data and values labelled.
My data frame is below:
structure(list(Average.DB.per.FA = c(0, 0.5, 1, 1.5, 2, 0, 0.5,
1, 1.5, 2, 0, 0.5, 1, 1.5, 2, 0, 0.5, 1, 1.5, 2, 0, 0.5, 1, 1.5,
2, 0, 0.5, 1, 1.5, 2), condition = c("CDD", "CDD", "CDD", "CDD",
"CDD", "CDD", "CDD", "CDD", "CDD", "CDD", "CDD", "CDD", "CDD",
"CDD", "CDD", "STD", "STD", "STD", "STD", "STD", "STD", "STD",
"STD", "STD", "STD", "STD", "STD", "STD", "STD", "STD"), percentage = c(0,
0.807218011, 0.192781989, 0, 0, 0, 0.737968015, 0.262031985,
0, 0, 0, 0.739096101, 0.260903899, 0, 0, 0, 0.466751289, 0.346156739,
0.170617491, 0.016474482, 0, 0.462997344, 0.331833715, 0.183359127,
0.021809813, 0.012053568, 0.47623097, 0.307175237, 0.182459607,
0.022080618)), row.names = c(NA, -30L), class = "data.frame")
I tried to use the following code:
ggplot(long_DF, aes(fill=Average.DB.per.FA, y=percentage, x=condition)) +
geom_bar(position=position_dodge(), stat="identity")
But the graph I obtained does not have bars add up to 1:
I would like to have graphs like below (which I created by Prism using the same set of data but Prism does not allow me to label bars with numbers):
Is there any way to reproduce the graph by Prism using R and add values to each stacked bar?
Appreciate your help and thanks in advance.