Skip to content

Instantly share code, notes, and snippets.

@juanchiem
Last active March 30, 2022 14:00
Show Gist options
  • Save juanchiem/95b4d7f8d1f55712e4eb96343fc519ba to your computer and use it in GitHub Desktop.
Save juanchiem/95b4d7f8d1f55712e4eb96343fc519ba to your computer and use it in GitHub Desktop.
library(tidyverse)
dat <- expand.grid(sev = seq(0.01, 0.99, 0.01),
inc = seq(0.01, 0.99, 0.01)) %>%
mutate(int = inc*sev)
dat %>%
ggplot(aes(inc, sev, fill= int)) +
geom_tile() +
viridis::scale_fill_viridis(discrete=FALSE, direction = -1)+
theme_bw() %+replace%
theme(plot.caption = element_text(hjust = 0, size = 10, face= "italic"))+
labs(
# x="Disease incidence", y="Disease severity", fill = "Disease\nintensity",
# caption = "Disease intensity = Disease incidence * Disease severity"
x="Incidencia", y="Severidad", fill = "Intensidad",
caption = "Intensidad = Incidencia * Severidad (ambos en proporcion 0 a 1)"
)+
geom_point(data = data.frame(sev = c(0.1,0.9), inc=c(0.9,0.1), int=0.09),
aes(x=inc, y=sev))+
geom_text(data = data.frame(sev = c(0.9,0.1), inc=c(0.1,0.9), int=0.09, lab=c("A", "B")),
aes(label=lab, vjust = 0, hjust = -0.5))
@juanchiem
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment