防止Plotly

时间:2017-06-30 06:23:58

标签: r plotly

我正在使用 Plotly 在R中绘制气泡图。但是当我使用 add_annotations 标签重叠并且很难阅读它们时。如何在剧情中防止这种重叠。我尝试了“geom_label_repel”,但它没有使用plotly,因为它给出了错误。

我的代码是

plot_ly(bubbleChartData, x = ~Category1, y = ~Category2,  type = 'scatter', mode = 'markers', size = ~BubbleSize,
       color = ~Category3, colors = brewer.pal(8,"Dark2"),
      marker = list( sizemode = 'diameter'), text=~Category4) %>%

add_annotations( showarrow=F,xanchor="right",xref = "x",ax = 20,
                  ay = -40,
                   yref = "y",x = ~Category1, y = ~Category2, text=~Category4,font = list(size = 10))%>%
layout(title = '',font=list(size=10),
       xaxis = list(
         title = "",
         showgrid=FALSE,
         showline=FALSE,
         tickfont = list(
           size = 16,
           color = 'rgb(0,0,0)'),
         titlefont = list(
           size = 18,
           color = 'rgb(0,0,0)')),
       yaxis = list(
         title = "",
         showgrid=FALSE,
         showline=FALSE,
         titlefont = list(
           size = 18,
           color = 'rgb(0,0,0)'),
         tickfont = list(
           size = 16,
           color = 'rgb(0,0,0)')),
       showlegend = F)

enter image description here

0 个答案:

没有答案