欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

R語(yǔ)言可視化ggplot2繪制24小時(shí)動(dòng)態(tài)血糖圖

 更新時(shí)間:2022年05月12日 10:34:19   作者:WTRD  
這篇文章主要為大家介紹了R語(yǔ)言可視化使用ggplot2繪制24小時(shí)動(dòng)態(tài)血糖,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

數(shù)據(jù)格式

sample=read.csv("sample.csv",header = T,stringsAsFactors = F)head(sample)

創(chuàng)建等距時(shí)間序列的方法(分鐘)

time=strptime("00:00:00","%H:%M:%S")+300*0:287 #沒有填日期的時(shí)候,默認(rèn)日期為今天

畫圖代碼

#time首先要轉(zhuǎn)換成 POSIXct 格式, 下面的breaks一樣,geom_datetime接受的只有POSIXct格式。
sample$time=as.POSIXct(sample$time)
#breaks都是自定義的,選取哪個(gè)時(shí)間點(diǎn)都可以
ggplot(sample,aes(x=time,y=Glucose,group=1))+geom_line()+scale_x_datetime(
  limits = c(as.POSIXct("2020-03-24 00:00:00 CST"),as.POSIXct("2020-03-24 23:59:59 CST")),
  breaks = c(as.POSIXct("2020-03-24 00:00:00 CST"),as.POSIXct("2020-03-24 04:00:00 CST"),as.POSIXct("2020-03-24 07:00:00 CST"),as.POSIXct("2020-03-24 12:00:00 CST"),as.POSIXct("2020-03-24 18:00:00 CST"),as.POSIXct("2020-03-24 22:00:00 CST")),
  labels = c("00:00","04:00","07:00","12:00","18:00","22:00")
             )+scale_y_continuous(
               breaks = c(6.0,6.1,6.5,7.0,7.5,8.0,8.5),labels = c("6.0","6.1","6.5","7.0","7.5","8.0","8.5")
             )+theme_bw() +
             theme(axis.text = element_text(size=16),axis.title = element_text(size=24)) #軸標(biāo)簽的大小
             + geom_hline(yintercept = c(6.1)) #添加一水平線,6.1是正常血糖高值

以上就是R語(yǔ)言可視化ggplot2繪制24小時(shí)動(dòng)態(tài)血糖的詳細(xì)內(nèi)容,更多關(guān)于ggplot2繪制動(dòng)態(tài)血糖的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論