Skip to content

Instantly share code, notes, and snippets.

@adisarid
Created August 20, 2020 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adisarid/1e100d5f4ff7526b3b8975b8494b3b07 to your computer and use it in GitHub Desktop.
Save adisarid/1e100d5f4ff7526b3b8975b8494b3b07 to your computer and use it in GitHub Desktop.
watch_levels <- tribble(~time, ~battery, ~status,
"2020-08-19 18:27", 0.94, "actual",
"2020-08-19 18:27", 0.94, "predicted",
"2020-08-19 22:42", 0.57, "actual",
"2020-08-20 06:42", 0, "actual") %>%
mutate(time = as.POSIXct(time)) %>%
bind_rows(tibble(time = as.POSIXct("2020-08-19 18:27") + (24+5)*60*60 + 120,
battery = 0,
status = "predicted")) %>%
mutate(status = case_when(status == "actual" ~ "What actually happened",
status == "predicted" ~ "What the watch predicted"))
watch_levels %>%
ggplot(aes(x = time, y = battery, color = status)) +
geom_point() +
geom_line(size = 1) +
scale_y_continuous(labels = scales::percent_format(1)) +
scale_x_datetime(breaks = "3 hours", date_labels = "%H:%M") +
saridr::theme_sarid() +
ylab("Battery level") +
xlab("Time") +
guides(color = guide_legend("")) +
theme(legend.position = "top") +
ggtitle("Samsung Galaxy watch started acting up...", subtitle = "Battery drains too fast")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment