In this data visualization project, I aim to delve into the intricate patterns of my sleeping habits and juxtapose them with broader sleeping trends in the United States. Sleep is a fundamental aspect of our lives, influencing our well-being, productivity, and overall health. By juxtaposing my personal sleep data with national trends, I hope to uncover unique insights into how my sleep patterns align or diverge from the larger community.

The population data was acquired between 2018-2022 and collected through the Sleep Cycle app from Northcube on iOS. It records the sleeping data of Sleep Cycle users in the US, including sleep time, heart rate, snore time and in total 22 variables. One of the important variable is sleep quality. It is based on a number of factors, but most importantly, time spent asleep, movements during the night and movements whilst awake in bed. My personal data was collected from October 1 to November 25. By using my apply watch and Sleep Cycle app, I recorded my sleep data for over two months. This project aims to show the relationship between various sleeping data and how my personal data can be connected with the public.

To begin with, two side by side violin plot (fig.1) can show the distribution of time alseep in hour for both the community (blue) and personal (red) data. The average distribution are approximately same. The distribution of community data on the left have a wider distribution with several outliers at the top and bottom. From the distribution of personal data on the right, I have more days with 10 hours sleep compared with the community. I also have some days with zero sleep hour.

After comparing the time asleep, I am interested in whether there is a difference in sleep quality between snore or not snore. By drawing two bot plots (fig.2) below, I can compare the difference for my personal data. The boxplot can also show the distribution of sleep quality. For the night that I snore, I tend to have wider range for sleep quality, and generally have better sleep quality compared with the night I didn’t snore.

There is an obvious difference personally between snore and not snore. On the contrary, it is interesting that for the community data, there is generally no difference in sleep quality. Based on the boxplot (fig.3) below, both are ranging from 100 to 50, with IQR 90 to 70. Compared with myself, I tend to have lower sleep quality when I am not snore.

As another factor that may affect sleep, I am also interested in whether the coffee will affect the time I take to fall asleep. I measured it by using the time I spent on bed and divided by time asleep. By using a violin plot (fig.4) to show the distribution, I found that if I drink coffee during that day, it usually take more time for me to fall asleep, usually would be 0.5-0.8 hour. For the day that I didn’t drink coffee, it usually take me 0-0.4 hour to fall asleep.

Alarm is a tool that everyone need in their life. I am interested in whether alarm will affect the sleep quality and time asleep. This interactive scatter plot shows the relationship between sleep quality and time asleep. You can choose to display my personal data or the community data. Also, you can choose to display the data with alarm and without alarm. A fitted line can help the reader better visualize the relationship. Based on the result, there is a positive relationship between time asleep (hours) and sleep quality, for both alarm mode. Moreover, observations that don’t have alarm tend to have better sleep quality than those who have alarm.

## 
## Listening on http://127.0.0.1:4999

To further examine the effect of alarm on both data, I draw a bar plot (fig.6) that shows the average time asleep (hour) by alarm mode. On average both the community and myself have longer average sleep hour when there is no alarm. Compare with the community data, I have a longer sleep hour than the average of community.

In addition to the alarm mode, I am interested in will the weather affect my sleep data each day. By drawing an animated scatter plot (fig.7), I show the relationship between time asleep and sleep quality with respect to weather. The plot shows that there is a positive relationship between time asleep and sleep quality. However, there seems no obvious difference among three weather. Sunny day has the most observations and it tends to have a larger span on both axis.

Regularity is key to good sleep, which is a gauge of how consistent a person’s sleep patterns are, based on the day-to-day variability. It is important to maintain a regular earliest possible bedtime and latest out of bed time over the week. The Sleep Cycle App measures the Regularity of users data in percentage form. Higher percentage means more regular schedule. As personal who don’t have regular schedule and stay up late, I am interested in the difference between my regularity and the community. Based on my personal data, this scatter plot (fig.8) shows a clear positive relationship between regularity and time asleep. Most of my data have regularity between 0.4 - 0.8. The color represent the sleep quality. For the night with higher regularity and high sleep hour, I tend to have a high sleep quality.

In fig.9, as for the community data, the relationship between regularity and time asleep isn’t very strong. The community’s regularity ranges from 0.5 to 1, which is more regular than me. On average, the night with higher regularity tends to have higher sleep quality.