Skip to content

Instantly share code, notes, and snippets.

@aammd
Created November 1, 2016 14:41
Show Gist options
  • Save aammd/7631d8c5e4ba722b64f030dcc6d2bbec to your computer and use it in GitHub Desktop.
Save aammd/7631d8c5e4ba722b64f030dcc6d2bbec to your computer and use it in GitHub Desktop.
annotating with rectangles
library(dplyr)
library(ggplot2)
dat <- data_frame(xs = runif(10, 2, 15),
ys = runif(10, 2, 15),
xe = rnorm(10, 2, 0.4),
ye = rnorm(10, 2, 0.4))
dat %>%
ggplot(aes(x = xs, y = ys)) +
geom_point() +
annotate("polygon",
xmin = dat$xs - dat$xe,
xmax = dat$xs + dat$xe,
ymin = dat$ys - dat$ye,
ymax = dat$ys + dat$ye)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment