I programmed this barplot with ggplot2, and it worked just fine. But it is al little bit too wide, so I would like to delete the fill legend and add it to the x-axis like in this image. How should I change my code?
Here is the data:
> dput(plot.Subject.means)
structure(list(Mode = structure(c(1L, 1L, 2L, 2L), .Label = c("silent",
"aloud"), class = "factor"), PlausibleFit = structure(c(1L, 2L,
1L, 2L), .Label = c("plausible", "implausible"), class = "factor"),
Stimulus = structure(c(2L, 2L, 2L, 2L), .Label = c("fist sent",
"second sent"), class = "factor"), Mean = c(241.743191964286,
258.42306547619, 304.836607142857, 333.330133928571), SE =
c(10.7086547532698,
12.5941104184202, 14.3157931004567, 17.5915009397571)), class =
"data.frame", row.names = c(NA,
-4L))
And the code for the figure
library(ggplot2)
Fig1.GD = ggplot(plot.Subject.means,
aes(x = Mode, y = Mean, fill = PlausibleFit)) +
geom_bar(stat = 'identity', position = 'dodge') +
geom_errorbar(aes(ymin = Mean - SE, ymax = Mean + SE),
width = .2, position = position_dodge(.9)) +
coord_cartesian(ylim = c(100, 400)) +
labs(title = "Gaze Duration Adults") +
xlab("Reading Mode") + ylab("Gaze Duration in ms") +
guides(fill = guide_legend(title = NULL))
Fig1.GD