Prevent Overlapping of labels in Plotly

Viewed 2640

I am plotting bubble chart using Plotly in R. But when I give labels using add_annotations labels overlap and its very difficult to read them. how to prevent this overlapping in plotly. I have tried "geom_label_repel" but its not working with plotly as it gives error.

My Code is

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 Answers
Related