Intro: Maximizing Sleep With Plotly and Sleep Cycle
As a competitive swimmer and high school student, every minute of sleep is valuable to me. Being diligent about studying, eating and sleeping are the keys to my success in both the school and the pool. If you do not share this lifestyle but still want to understand your sleep patterns and discover how to maximize your sleep potential, you might find this valuable. With a collaboration of two essentials, Plotly and Sleep Cycle, you will be well on your way to better sleep. The Sleep Cycle mobile application utilizes a smartphone's accelerometer to track each night of sleep. I've logged just under two hundred nights thus far. The app traces your patterns of sleep, but unfortunately, the data gathered by the application is not displayed in an easy, understandable way. That is where Plotly comes in!
Step 1: Gathering Data
This step is quite straight forward, download the Sleep Cycle app, place it on your bed, while plugged into a charger, and sleep the night away. You'll need a minimum of seven nights in order to get a sleep quality percentage.
Step 2: Export the Data
Once you have a decent amount of nights, and you're ready to display them in Plotly, you'll need to export the data form Sleep Cycle. Thankfully, Sleep Cycle makes this incredibly easy. Go to settings>advanced>export database and send the file to a desirable target that can be opened on a PC or Mac. (The file will save as a .csv)
Step 3: Adding the Data to Plotly
The first thing you'll want to do is obtain a Plotly account. Once done, create a new project, and import the csv file. Once the file is selected, the data will automatically input. If you would rather experiment with my data rather than log nights, it is provided!
Step 4: Display the Data (the Fun Part)
For this next step, it is up to you what data you would like to see. For me, I chose to display sleep quality percentage each night. For that, I selected the date to be X and the quality to be Y. Once you've selected the desired date, click line plot. (You can do a line plot or a scatterplot, I chose a scatterplot) At first glance, you should see some sort of relationship, but for a more detailed version and r-value, click Fit Trace, add a linear fit, and run it.
Have fun playing around with Plotly! Customize the look to meet your needs, display the data you want to see, and be on your way to maximizing your sleep.