I am using plotly 4.5.2 in R. I have created a scatterplot which is sized on a variable, the issue is these sizes are also reflected in the legend which makes them hard to read.
I want my graph to remain the same, with the only exception being the size of the bubbles in the legend. These bubbles can either be set to all be the same size or scaled to a smaller size. Importantly, the sizes in the graph must remain the same.
Please find reproducible code here:
library(plotly)
data <- data.frame(name = c('test1', 'test2', 'test3', 'test4'),
x = c(1, 15, 90, 45),
y = c(9, 43, 43, 53),
size = c(10000, 50000, 90000, 3000),
colour = c("rgba(230, 42, 56, 0.3)", "rgba(76, 175, 80, 0.3)",
"rgba(32, 169, 242, 0.3)", "rgba(255, 193, 7, 0.3)")
)
plot <- plot_ly(data = data) %>%
add_trace(x = ~x,
y = ~y,
mode = 'markers',
type = 'scatter',
color = ~name,
marker = list(
color = ~colour,
opacity = 1,
showlegend=T),
size = ~size)
Thank you