Skip to content

Instantly share code, notes, and snippets.

@malcolmbarrett
Created May 12, 2019 14:13
Show Gist options
  • Save malcolmbarrett/aced498445412d7fab462a4da0bb42d0 to your computer and use it in GitHub Desktop.
Save malcolmbarrett/aced498445412d7fab462a4da0bb42d0 to your computer and use it in GitHub Desktop.
library(ggplot2)
df <- data.frame(
y = c(42, 71, 76, 79),
ci_lower = c(40, 69, 74, 77),
ci_upper = c(44, 73, 78, 81),
year = c("baseline", "year 1", "year 2", "year 3")
)
ggplot(df, aes(x = year, y = y)) +
geom_col(fill = "#0072B2", width = .7) +
geom_errorbar(
aes(ymin = ci_lower, ymax = ci_upper),
width = 0,
size = .9
) +
geom_text(aes(y = 3, label = y), col = "white", size = 5) +
labs(
y = "Proportion of all HIV+ with viral suppression",
x = element_blank()
) +
theme_minimal(14)
ggplot(df, aes(x = year, y = y)) +
geom_errorbar(
aes(ymin = ci_lower, ymax = ci_upper),
col = "#0072B2",
width = 0,
size = .9
) +
geom_point(col = "#0072B2", size = 2) +
geom_text(
aes(label = y),
nudge_x = .15,
size = 5
) +
labs(
y = "Proportion of all HIV+ with viral suppression",
x = element_blank()
) +
ylim(0, NA) +
theme_minimal(14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment