小编raj*_*ind的帖子

防止 Plotly 中的标签重叠

我正在R 中使用Plotly绘制气泡图。但是当我使用add_annotations给出标签时,标签重叠并且很难阅读它们。如何在plotly 中防止这种重叠。我试过“geom_label_repel”,但它不能很好地工作,因为它会出错。

我的代码是

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 …
Run Code Online (Sandbox Code Playgroud)

r plotly

5
推荐指数
0
解决办法
2333
查看次数

标签 统计

plotly ×1

r ×1