标记大小

时间:2019-09-29 13:01:47

标签: r plotly

我无法使绘图标记大小正常工作。

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')

我添加了一个带有该列的文本框,该列应该用作标记大小,并且可以正常工作,因此,如果遇到任何有关大小错误的帮助,将不胜感激。

1 个答案:

答案 0 :(得分:1)

希望这会有所帮助,其中尺寸由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')