At the moment I am replicating/updating certain graphics for a poster presentation. I managed to replicate colours, values, the bar-style and background of the graphic. But there's an arrow-label missing, highlighting a value-difference. I wonder whether there's an useful option via ggplot (lines or arrows), worth the effort - alternatively I have to draw some arrows with another graphic-software ...
Here's what I try to do:
Here's what I already have:
The data and code:
weight <- c(113.2158, 108.5404, 98.75564, 93.93759)
sex <- c("m","m", "f","f")
time <- c("t0", "t1", "t0", "t1")
data <- data.frame(weight, sex, time)
library(ggplot2)
ggplot(data, aes(x = factor(sex), y = weight, group=time, fill=factor(time))) +
geom_bar(position="dodge", stat = "identity") +
theme(legend.position = c(0.8, 0.9),
axis.ticks = element_blank(),
axis.title.x=element_blank(),
axis.title.y=element_blank(),
panel.background = element_blank(),
panel.grid.major.x = element_blank() ,
panel.grid.major.y = element_line( size=.1, color="grey" ),
legend.key = element_rect(size = 2),
legend.key.size = unit(1.5, 'lines')) +
guides(fill=guide_legend(title="time")) +
scale_fill_manual(values=c("#b6181f", "#f6b8bb"), labels=c("t0", "t1")) +
scale_x_discrete(labels = c("male, n = 57", "female, n = 133")) +
coord_cartesian(ylim = c(90,120)) +
scale_y_continuous(breaks=c(90,95,100,105,110,115,120)) +
geom_text(aes(x=factor(sex), label=round(weight, digits=2)), position = position_dodge(width = 1), vjust = -0.25) +
geom_line(aes(x=factor(sex), label=round(weight, digits=2)), position = position_dodge(width = 1), vjust = -0.25)
Thank you very much for ideas.