Vẽ số đo huyết áp theo mẫu tại https://www.vertex42.com/ExcelTemplates/blood-pressure-chart.html
library(ggplot2)
# Tạo dữ liệu đo huyết áp
BloodPressure <- data.frame(
dia = runif(30, min = 60, max = 80),
sys = runif(30, min = 90, max = 120)
)
# Cấp độ
level <- c("HIGH: STAGE 2", "HIGH: STAGE 1", "PREHYPERTENSION", "NORMAL", "LOW**")
col <- c("#ED5A69", "#F07B7F", "#F7A649", "#78BB66", "#4BC0B5")
d <- data.frame(
x1 = c(40, 40, 40, 40, 40),
x2 = c(120, 100, 90, 80, 60),
y1 = c(40, 40, 40, 40, 40),
y2 = c(180, 160, 140, 120, 90),
level = factor(level, levels = level)
)
# Plot
ggplot() +
geom_rect(data = d, aes(xmin = x1, xmax = x2, ymin = y1, ymax = y2, fill = level),
color = "white", size = 2) +
scale_fill_manual(values = col) +
geom_point(data = BloodPressure, aes(dia, sys),
alpha = 0.5,size = 3, shape = 21, color = "white", fill = "blue") +
scale_x_continuous(breaks = c(40,60, 80, 90, 100, 120),
labels = c(40, 60, 80, 90, 100, "120+"), expand = c(0,1)) +
scale_y_continuous(breaks = c(40, 90, 120, 140, 160, 180),
labels = c(40, 90, 120, 140, 160, "180+"), expand = c(0, 0)) +
annotate("text", x = 45, y = c(80,110, 130, 150, 170), label = rev(level), hjust = 0) +
theme_minimal() + theme(legend.position = "none") +
labs(x = "Diastolic", y = "Systolic")