带有气泡图中的图像的气泡

时间:2018-11-06 10:00:09

标签: r plotly r-plotly

是否可以为R中的绘图图中的气泡分配图像而不是颜色?

图形的代码示例如下,我想将国家/地区的标志分配给气泡而不是颜色。

   library(plotly)

   data <- data.frame( "country" = c("United States"," Indonesia", "Brazil"), "population" = c(329256465,262787403, 208846892) )

      plot<- plot_ly(data, x = ~country, y = ~population,  type = 'scatter', mode = 'markers', size = ~population, color = ~country, colors = 'Paired',
           marker = list(opacity = 0.5, sizemode = 'diameter'),
           hoverinfo = 'text',
           text = ~paste( country, '<br>Population:', population)) %>%
    layout(title = 'Population Dist',
     xaxis = list(showgrid = FALSE),
     yaxis = list(showgrid = FALSE),
     showlegend = FALSE)
  plot

从互联网获取的图像示例如下

enter image description here

0 个答案:

没有答案