简体   繁体   中英

Plotly marker size

I am having trouble getting the plotly marker size to work correctly.

test <- data.frame(a = c(1,2,3,5,3,4,2,6,4,5),
                   b = c(12,14,11,10,3,7,5,8,15,2),
                   c = c("d","e","d","f","e","d","f","e","e","f"),
                   d = c(5,5,10,15,10,15,5,10,5,15))
plot_ly()%>%
add_trace(data = test, x = ~a, y = ~b, mode = 'markers', type = 'scatter',
          color = ~c, colors = c("red", "blue", "green"),
          marker = list(size = ~d), text = ~d, hoverinfo = 'text')

I added a text box with the column that is supposed to be used as the marker size and it works correctly, so any help with what is going wrong with the size would be appreciated.

Hope this helps, where sizes are defined by d :

test <- data.frame(a = c(1,2,3,5,3,4,2,6,4,5),
                   b = c(12,14,11,10,3,7,5,8,15,2),
                   c = c("d","e","d","f","e","d","f","e","e","f"),
                   d = c(5,5,10,15,10,15,5,10,5,15))
plot_ly()%>%
  add_trace(data = test, x = ~a, y = ~b, mode = 'markers', type = 'scatter',
            color = ~c, colors = c("red", "blue", "green"),
            size = ~d, text = ~d, hoverinfo = 'text')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM