Updated:
How can I modify the following ggplot to get the following:
X axis should be adjusted for months i.e. baseline to 6 months should be shorter, 6 months to 24 months should be longer depending on the number of months in between the time points. (solution below)
Include a break (say at 36 months) in X axis between 24 months to 48 months.
Make the plot larger by reducing the white space before baseline and after 48 months. (solution below)
Thanks for your help!
fat <- structure(list(study_group = structure(c(1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L), .Label = c("Intervention group", "Control group"
), class = "factor"), mean1 = c(37.02, 32.95, 34.18, 36.38, 37.1,
37.27, 37.64, 38.22), se1 = c(0.22, 0.3, 0.35, 0.38, 0.23, 0.35,
0.28, 0.32), timepoint1 = c(0, 6, 24, 48, 0, 6, 24, 48)), row.names = c(3L,
7L, 11L, 15L, 19L, 23L, 27L, 31L), class = "data.frame")
ggplot(fat, aes(timepoint1, mean1, colour = study_group)) +
geom_point(size=2) +
geom_line(size=1.2) +
geom_errorbar(aes(ymin=mean1-se1, ymax=mean1+se1), width=1, size=1) +
scale_x_continuous(
breaks = c(0, 6, 24, 36, 48),
labels = c("Baseline", "6 months", "24 months", "36 months", "48 months"),
expand = c(0.05, 0))