df$tea_numeric <- as.numeric(df$tea_type)
xax <- list(title = "Time of Tea", titlefont = list(family = "Poppins",
size = 14))
yax <- list(title = "Sleep Duration", titlefont = list(family = "Poppins",
size = 14))
zax <- list(title = "Tea Type", titlefont = list(family = "Poppins",
size = 14))
plot_ly(df, x = ~time, y = ~sleep, z = ~tea_numeric, color = ~tea_type,
colors = c("grey", "green", "skyblue"), type = "scatter3d",
mode = "markers", marker = list(size = 8)) %>%
layout(scene = list(xaxis = xax, yaxis = yax, zaxis = zax),
title = list(text = "3D View: Time, Sleep, and Tea Type",
font = list(family = "Poppins", size = 18)))
Graph Explanation : 3D scatter with time of tea on the x-axis, sleep hours on the y-axis, and tea type on the z-axis, dot colors are gray for Black, green for Green, and blue for Herbal, and the dots show that drinking tea later goes with less sleep while types were often consumed at different times.