Last active
March 31, 2016 01:16
-
-
Save ignisf/eac71ea9651cd472c9dac657e54fc56e to your computer and use it in GitHub Desktop.
Blood Pressure Plot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(ggExtra) | |
systolic = c(124, 133, 129, 145, 150, 152, 141, 136, 130, 150, 150, 126, 121, 130, 130, 108, 134) | |
diastolic = c(80, 80, 83, 93, 92, 94, 83, 76, 89, 90, 92, 81, 73, 80, 68, 70, 80) | |
blood_pressure = data.frame(systolic, diastolic) | |
p <- ggplot(blood_pressure, aes(diastolic,systolic)) + geom_point(color="firebrick") + theme_bw() + | |
labs(x="Diastolic (mmHg)", y="Systolic (mmHg)", title="Blood Pressure") + | |
scale_x_continuous(breaks = round(seq(50, 120, by = 10),1)) + | |
scale_y_continuous(breaks = round(seq(90, 200, by = 10),1)) + | |
annotate("rect", xmin = 50, xmax = 120, ymin = 90, ymax = 200, color = "red", alpha = .01) + | |
annotate("rect", xmin = 50, xmax = 110, ymin = 90, ymax = 180, color = "pink", alpha = .01) + | |
annotate("rect", xmin = 50, xmax = 100, ymin = 90, ymax = 160, color = "orange", alpha = .01) + | |
annotate("rect", xmin = 50, xmax = 90, ymin = 90, ymax = 140, color = "yellow", alpha = .01) + | |
annotate("rect", xmin = 50, xmax = 85, ymin = 90, ymax = 130, color = "green", alpha = .01) + | |
annotate("rect", xmin = 50, xmax = 80, ymin = 90, ymax = 120, color = "blue", alpha = .01) + | |
annotate("text", x = 60, y = c(190, 170, 150, 135, 125, 115), label = c("Grade 3", "Grade 2", "Grade 1", "High normal", "Normal", "Optimal"), alpha = .3) | |
ggExtra::ggMarginal(p, type = 'boxplot', size = 8, fill = "white") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment