Skip to content

Instantly share code, notes, and snippets.

@juanchiem
Last active September 22, 2020 18:38
Show Gist options
  • Save juanchiem/1f9e468804073c762c0093b196ed5e3d to your computer and use it in GitHub Desktop.
Save juanchiem/1f9e468804073c762c0093b196ed5e3d to your computer and use it in GitHub Desktop.
library(ggplot2)
pic <- magick::image_read("https://i.imgur.com/GOjBfBu.png")
(tibble::tribble(
~patogeno, ~hum_min, ~hum_max, ~temp_min, ~temp_max,
"Esc",48L,58L,8L,15L,
"Red",36L,46L,10L,18L,
"MB",48L,58L,20L,24L,
"Ram",16L,26L,15L,20L) %>%
mutate(hum = (hum_min+hum_max)/2,
temp = (temp_min+temp_max)/2,
a =temp_max - temp_min,
b = hum_max - hum_min,
color = case_when(
str_detect(patogeno, "roya") ~ "red",
TRUE ~ "blue")) %>%
ggplot(aes(x0 = temp, y0 = hum,
a = a/2, b = b, angle = 0)) +
ggforce::geom_ellipse() +
geom_text(aes(x = temp, y=hum, label=patogeno), fontface="bold")+
cowplot::theme_minimal_grid() +
labs(x = "Temperatura (°C)", y = "Humedad (horas de mojado)")+
guides(col = F)+
scale_x_continuous(
limits = c(0, 30),
breaks = scales::extended_breaks(Q = c(30, 10)))+
ggpubr::background_image(pic))
# https://git.io/JUzp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment