4

I have created a graphic with ggplot2 and I would like to know if its possible to put an image and how instead of a label using ggplot2.

My code:

ggplot(data, aes(x=DRTG, y=ORTG)) +
  geom_point(colour = "#000000") + 
  ggtitle("Gráfico Liga DIA: Ratio Ofensivo / Ratio Defensivo (hasta jornada 8)") +
  #geom_text(label=rownames(data), colour = "#000000", nudge_x = nudgeX, nudge_y = nudgeY, size = 4, fontface = "bold", check_overlap = F) +
  geom_text_repel(label=rownames(data), fontface = "bold") +
  geom_point(data=pointMedia, aes(x=mediaDRTG, y=mediaORTG, colour="red", size = 1)) + 
  geom_vline(xintercept = pointMedia[, "mediaDRTG"], colour = "green") + 
  geom_hline(yintercept = pointMedia[, "mediaORTG"], colour = "blue") +
  geom_text(data=pointMedia, aes(x=mediaDRTG, y=mediaORTG, label="Liga DIA"), nudge_x = 0, nudge_y = 1, colour = "red", fontface = "bold") +
  theme(legend.position = "none") +
  geom_abline(intercept =0 , slope = 1, colour = "orange")+ xlim(70,115) + ylim(70,115)

My graphic:

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
José Carlos
  • 2,850
  • 12
  • 59
  • 95
  • 3
    https://cran.r-project.org/web/packages/ggimage/vignettes/ggimage.html – hrbrmstr Nov 24 '17 at 11:03
  • Thank you for your help!!! hrbrmstr – José Carlos Nov 24 '17 at 11:08
  • 1
    The problem with ggimage (as I found out today) is that it's incredibly difficult to make it keep the correct image aspect ratio. See [here](https://stackoverflow.com/questions/47479779/can-geom-image-from-the-ggimage-package-be-made-to-preserve-the-image-aspect-r) for details. You can use `draw_image()` from cowplot if you have only a small number of images you want to draw. – Claus Wilke Nov 24 '17 at 23:28

0 Answers0