【问题标题】:Use images as points ggplot2使用图像作为点 ggplot2
【发布时间】:2021-10-21 23:21:09
【问题描述】:

我正在尝试使用下一张图片作为点http://phylopic.org/image/95981b99-36cc-413e-bf59-0454fde43c85/

我的数据:

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))

我有这个基本情节:

 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")

如果我能得到相同的颜色(点数 = imagen)可能会很疯狂,但没有必要

我尝试使用 rphylopic 包https://cran.r-project.org/web/packages/rphylopic/rphylopic.pdf

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

但我错过了一些东西,因为我无法获得欲望情节。我还检查了这个论坛中的其他问题,但我还是没有得到我的情节:-(。
如果有人可以帮助我。

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    使用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])
    

    【讨论】:

      猜你喜欢
      • 2020-08-06
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-07
      • 2020-11-20
      • 2015-10-17
      • 1970-01-01
      相关资源
      最近更新 更多