Get the App
SLTechnology News&Howtos  ›  Development  › 

R language Visualization ggplot2 how to draw 24-hour dynamic Blood glucose Map

Shulou Source: shulou.com Published: 2022-05-31 17:42:53 10月02日 Update

This article mainly introduces the relevant knowledge of "how to draw 24-hour dynamic blood glucose map with R language visualization ggplot2". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "R language visualization ggplot2 how to draw 24-hour dynamic blood glucose map" can help you solve the problem.

Data format sample=read.csv ("sample.csv", header = Theme stringsAsFactors = F) head (sample)

The method of creating equidistant time series (minutes) time=strptime ("00:00:00", "% H:%M:%S") + 300000breaks 287 # when there is no date, the default date is today's drawing code # time must first be converted to POSIXct format, like the following breaks, geom_datetime accepts only POSIXct format. Sample$time=as.POSIXct (sample$time) # breaks are customized Any time point can be chosen by ggplot (sample,aes (X-ray timekeeper lucky Group1) + 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, labels = c) + theme_bw () + theme (axis.text = element_text (size=16)) Axis.title = element_text (size=24)) # size of axis label + geom_hline (yintercept = c (6.1)) # add a horizontal line 6.1 is a high value of normal blood glucose.

This is the end of the introduction of "how to draw 24-hour dynamic blood glucose map with R language visualization ggplot2". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Blood sugar dynamic hour language visualization format knowledge method date time industry different practical code content only size practicality actual sequence Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB OPPO Reno macOS Xiaomi Apple