睡眠时间

睡眠时间

这是学习zonination/sleep-nsf的笔记,对NSF推荐的睡眠时长进行可视化。

绘图需要的数据集:
sleep.csv

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
setwd("~/Desktop/睡眠时间")
library(readr)
sleep <- read_csv("sleep.csv")
library(ggplot2)
library(reshape2)

ggplot(sleep) +
geom_ribbon(aes(x = age,
ymin = min,
ymax = max,
fill = Recommendation),
alpha = 0.7,
colour = "black") +
scale_fill_manual(values = c(
"#bdd7e7", "#3182bd"
), lab = c(
" 可以接受", " 推荐"
)) +
scale_y_continuous(limits = c(0, 20)) +
labs(title = "图:推荐睡眠时长",
subtitle = "数据来源:https://sleepfoundation.org",
x = "年龄",
y = "睡眠时间") +
theme_bw(base_size = 15, base_family = 'STSong') +
theme(plot.title = element_text(hjust = 0.5)) +
theme(plot.subtitle = element_text(hjust = 0.5)) +
theme(legend.title = element_blank())

看来我现在每天就是随10多个小时也是可以接受的!

# R

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×