Use images as points ggplot2

Viewed 196

I am trying to use the next image as points http://phylopic.org/image/95981b99-36cc-413e-bf59-0454fde43c85/

My data :

structure(list(X = 1:4, Variables = c("Slope_Dv", "Slope_Dv", 
"Slope_Dv", "Slope_Dv"), Estimate = c(-5.06, 35.58, 25.55, -1.48
), se = c(0.09, 0.09, 0.1, 0.09), ci.lb = c(0.04, -0.32, -0.5, 
-0.5), ci.ub = c(0.42, 0.05, -0.11, -0.11), Models = c("Model_Abun", 
"Model_Richness", "Model_Diversity", "Model_Evenness"), imagen = c("S_Dv", 
"S_Dv", "S_Dv", "S_Dv")), class = "data.frame", row.names = c(NA, 
-4L))

I have this basic plot :

 ggplot(df3, aes(Models,Estimate,ymin=Estimate-se, ymax=Estimate+se)) +
  geom_pointrange(aes(color= Estimate), size=1)  + 
  scale_color_gradient(low="red", high="blue") +
  theme_bw() + labs(colour = "S-stadistic")

Could be fantistic if I can get the same colors (points = imagen), but its no necessary

I tried using rphylopic Package https://cran.r-project.org/web/packages/rphylopic/rphylopic.pdf

https://cran.r-project.org/web/packages/rphylopic/readme/README.html

But I am missing something, because I cant get the desire plot. Also I checked other questions in this foro but again I am no getting my plot :-(.
If someone could help me.

1 Answers

Using ggimage,

df3$image <- rep(c( "http://phylopic.org/assets/images/submissions/95981b99-36cc-413e-bf59-0454fde43c85.512.png"), 4)

ggplot(df3, aes(Models,Estimate,ymin=Estimate-se, ymax=Estimate+se, color = Estimate)) +
  geom_pointrange(aes(color= Estimate), size=1)  + 
  scale_color_gradient(low="red", high="blue") +
  theme_bw() + labs(colour = "S-stadistic")  + geom_image(image = df3$image[1])

enter image description here

Related