Here is what I have now:
graph_POST %>%
mutate(day = lubridate::day(Date)) %>%
pivot_longer(Standing:New_Sitting, names_to = "Posture") %>%
ggplot(aes(x = Time, y = value, color = Posture))+
geom_point(size=0.5)+
scale_y_continuous(limits = c(0.5,4.5), expand = expansion(0)) +
facet_wrap(~day, scales = "free_x") +
labs(title = "Posture vs. Time (POST)") +
theme(axis.title.y = element_blank(),
axis.text.y = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank())
I need the x axes to be the same for all my plots in my "facet" (8am-5pm) with a tick every hour. I've tried to do similar to my y axes, but it seems to not like that for some reason:scale_x_continuous(limits = c(8:00,5:00))
Please let me know if you have any questions or need clarifications
> dput(head(graph_POST,30))
structure(list(Date = structure(c(19145, 19145, 19145, 19145,
19145, 19145, 19145, 19145, 19145, 19145, 19145, 19145, 19145,
19145, 19145, 19145, 19145, 19145, 19145, 19145, 19145, 19145,
19145, 19145, 19145, 19145, 19145, 19145, 19145, 19145), class = "Date"),
Time = structure(c(1654182900, 1654182901, 1654182902, 1654182903,
1654182904, 1654182905, 1654182906, 1654182907, 1654182908,
1654182909, 1654182910, 1654182911, 1654182912, 1654182913,
1654182914, 1654182915, 1654182916, 1654182917, 1654182918,
1654182919, 1654182920, 1654182921, 1654182922, 1654182923,
1654182924, 1654182925, 1654182926, 1654182927, 1654182928,
1654182929), class = c("POSIXct", "POSIXt"), tzone = ""),
Axis1 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), Axis2 = c(0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), Axis3 = c(0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0), VM = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), Standing = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), Stepping = c(0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0), Cycling = c(0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0), New_Sitting = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), Counter = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), row.names = c(NA,
30L), class = "data.frame")
EDIT
graph_POST %>%
mutate(day = lubridate::day(Date)) %>%
pivot_longer(Standing:New_Sitting, names_to = "Posture") %>%
ggplot(aes(x = Time, y = value, color = Posture)) +
geom_point(data = data.frame(
Time = as.POSIXct(rep(unique(graph_POST$Date), 2)) +
rep(c(8, 17) * 3600, each = length(unique(graph_POST$Date))),
value = 1, Posture = "Cycling",
day = rep(lubridate::day(unique(graph_POST$Date)), 2)), alpha = 0) +
geom_point(size=0.5)+
scale_y_continuous(limits = c(0.5,4.5), expand = expansion(0)) +
scale_x_datetime(date_labels = "%H:%M",
breaks = rep(as.POSIXct(unique(graph_POST$Date)), 4) +
rep(c(8, 11, 14, 17) * 3600,
each = length(unique(graph_POST$Date)))) +
facet_wrap(~day, scales = "free_x") +
labs(title = "Posture vs. Time (POST)") +
theme(axis.title.y = element_blank(),
axis.text.y = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank())