How to color plotly bubble chart by any category variable

Am using R to build my charts with Plotly

I have data set as below and stored in data frame dt

dt = data.frame(category=c(“A”,“B”,“C”),X=c(1,2,3),Y=c(3,4,5))

and am trying to plot bubble chart using plotly as below and color it by category

plot_ly(dt, x =X, y = Y, size = X, mode = “markers”,color = category)
But it is not showing the bubble chart properly.

Please help.

Hi, yeah there appears to be a bug with the plot_ly function.
What you could do in the meantime is use the ggplotly function instead, which seems to work.

g <- ggplot(data=dt) + geom_point(mapping=aes(x = X, y = Y, colour = category, size = X))