Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Plotly bubble charts in R remove automatically added text

Plotly bubble charts in R automatically adds size information to text.


How can I prevent Plotly from adding those texts? Or remove those texts?


Just do this:

d <- diamonds[sample(nrow(diamonds), 1000), ]
plot_ly(d, x = carat, y = price, size = carat, mode = "markers", hoverinfo = "none")

Thanks. But I do not want to remove all the text. Actually I need to label the bubbles (with state abbr.), so my mode is markers+text. The automatically added size information makes the labels unreadable.

If you use the size parameter plotly will by default add the size tooltip. One workaround is:

Nnote that the size parameter inside marker needs to be in pixels hence you’ll need to scale it up.

d <- diamonds[sample(nrow(diamonds), 1000), ]

hovertxt <- paste("color = ", d$color, "<br>",
                  "Clarity = ", d$clarity, "<br>",
                  "Cut = ", d$cut, "<br>")

plot_ly(d, x = carat, y = price, mode = "markers", 
        marker = list(size = carat * 8),
        hoverinfo = "text", text = hovertxt)


Thanks! This sovled my problem.