You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to make a plot that has facets and uses ggbreak. My issue is that the facet titles are repeating before/after each break. Ideally, the facet title would appear just once, centrally, above each facet (row). Is this possible?
I am attempting to make a plot that has facets and uses ggbreak. My issue is that the facet titles are repeating before/after each break. Ideally, the facet title would appear just once, centrally, above each facet (row). Is this possible?
plot_data %>%
filter(School %in% schools_plot1) %>%
ggplot(aes(x = Date, group = School)) +
geom_line(data = . %>% filter(Date < break_start1),
aes(y = Attendance_NA), color = "#989898") +
geom_line(data = . %>% filter(Date > break_end1 & Date < break_start2),
aes(y = Attendance_NA), color = "#989898") +
geom_line(data = . %>% filter(Date > break_end2),
aes(y = Attendance_NA), color = "#989898") +
geom_point(aes(y = Attendance_NA), color = "#989898") +
geom_point(aes(y = Attendance_NA), shape = 21, stroke = 0.5, color = "black") +
geom_point(data = filter(plot_data,
School %in% schools_plot1 & Attendance < 10 | NA),
aes(y = 0), color = "red", size = 1, alpha = 0.5) +
labs(
x = "",
y = "Number of students attending school") +
theme_minimal() +
theme(
axis.text.x = element_text(angle = 45, hjust = 1, size = 12, color = "black"),
panel.grid.major.y = element_line(color = "#CCCCCC", size = 0.2),
panel.grid.minor.y = element_blank(),
panel.grid.minor.x = element_blank(),
axis.text.y = element_text(size = 12, color = "black", margin = margin(r = 5)),
axis.title.y = element_text(size = 14, color = "black", margin = margin(r = 10)),
strip.text = element_text(size = 12, color = "black", margin = margin(b = 10)),
strip.background = element_blank(),
panel.spacing.y = unit(1.2, "lines"),
legend.position = "none",
axis.text.x.top = element_blank()
) +
facet_wrap(~School, nrow = 5, scales = "free_y") +
scale_x_date(date_breaks = "1 week", date_labels = "%b %d", expand = c(0.05, 0)) +
scale_x_break(c(break_start1, break_end1, break_start2, break_end2), space = 1.2)
The text was updated successfully, but these errors were encountered: