Skip to content

Instantly share code, notes, and snippets.

@hypercompetent
Last active December 29, 2020 21:51
Show Gist options
  • Save hypercompetent/ce1243c44d5153baa049ddc68aaf2357 to your computer and use it in GitHub Desktop.
Save hypercompetent/ce1243c44d5153baa049ddc68aaf2357 to your computer and use it in GitHub Desktop.
library(reshape2)
library(ggplot2)
df <- melt(volcano[20:44,10:34])
names(df) <- c("x","y","val")
rect <- data.frame(st = 5, en = 20)
ggplot() +
geom_point(data = df,
aes(x = x, y = y, color = val),
size = 5) +
geom_rect(data = rect,
aes(xmin = st, xmax = en,
ymin = st, ymax = en),
color = "black",
size = 2,
fill = NA) +
scale_color_gradient2(
low = "blue",
mid = "white",
high = "red",
limits = c(100, 200),
midpoint = 150) +
theme_bw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment