- Below is an example of output vs time.
- I have used duration to color the line.
- I also want to include energy level in plot. How can I use rectangle panel (
geom_rect
) in the plot background.
library(tidyverse)
tbl <- tibble(time = 1:100,
output = - time^2 + 5*time,
duration = c(rep("start", 30), rep("mid", 40), rep("end", 30)),
energy = c(rep("high", 40), rep("medium", 30), rep("low", 30)))
ggplot(data = tbl,
aes(x = time,
y = output,
color = duration)) +
geom_line() +
theme_bw()