library(plotly)
## Warning: package 'plotly' was built under R version 4.3.2
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(ggplot2)
sleep<-read.csv("C:/Users/jie77/OneDrive/Desktop/4Yr - Sem 1/STAT 3280 Data Visualization/Project/Sleep_Efficiency.csv")


plot1 <- plot_ly(sleep,x = ~Sleep.duration, y = ~REM.sleep.percentage, frame = ~Gender, 
                type = 'scatter', mode = 'markers', 
                text = ~paste('Gender: ', Gender, '<br>REM Sleep: ', REM.sleep.percentage, '<br>Sleep Duration: ', Sleep.duration))%>%layout(xaxis = list(title = 'Sleep Duration'),
         yaxis = list(title = 'REM Sleep Percentage'),
         title = 'Sleep Duration vs REM Sleep % by Gender',
         plot_bgcolor = '#ffffff',  
         paper_bgcolor = '#ffffff') 

plot1