p_gg <- ggplot(Batch4_eval, aes(x = time_hrs)) +
geom_ribbon(aes(ymin = lcl, ymax = ucl), fill = "#d9e6f2", alpha = 0.6) +
geom_line(aes(y = cl), colour = "darkgreen", linetype = "dashed", linewidth = 0.8) +
geom_line(aes(y = ucl), colour = "firebrick3", linetype = "dashed", linewidth = 0.7) +
geom_line(aes(y = lcl), colour = "firebrick3", linetype = "dashed", linewidth = 0.7) +
geom_line(aes(y = pH), colour = "black", linewidth = 0.9) +
geom_point(aes(y = pH, colour = status), size = 2) +
scale_colour_manual(
values = c("In Control" = "green3", "Above UCL" = "firebrick1", "Below LCL" = "firebrick1")
) +
labs(
title = "Time-Based Control Chart for Run 4",
caption = "Limits mean±3SD calculated from 3 reference runs (all runs except 4)",
x = "Time (hours)",
y = "pH"
) +
theme_bw(base_size = 12) +
theme(legend.position = "bottom")
p_gg;ggplotly(p_gg, dynamicTicks = TRUE)