使用第三个变量添加大小和颜色以使用plotly进行绘制

时间:2018-10-10 08:36:09

标签: r plotly

我想使用plotly控制标记的颜色和大小,例如此处的示例:

2018-10-10T08:04:50.754Z [info]: Master 9584 is running

2018-10-10T08:04:52.273Z [info]: Express server id:11592 listening on port 2222

2018-10-10T08:04:52.334Z [info]: Express server id:2828 listening on port 2222

2018-10-10T08:04:52.352Z [info]: Express server id:2580 listening on port 2222

2018-10-10T08:04:52.383Z [info]: Express server id:4540 listening on port 2222

2018-10-10T08:04:58.330Z [info]: project filters were sent to admin in precess id:4540

2018-10-10T08:04:58.377Z [info]: project filters were sent to admin in precess id:4540

2018-10-10T08:04:58.447Z [info]: project filters were sent to admin in precess id:4540

2018-10-10T08:04:58.491Z [info]: project filters were sent to admin in precess id:4540

2018-10-10T08:04:58.538Z [info]: project filters were sent to admin in precess id:4540

现在,我想使用另一个变量来控制大小,并随时间进行调整。然后,它提出了一个奇怪的分组解决方案。

OMNet++ libraries not yet compiled: library files for configuration 

"gcc-debug" are missing from C:\omnetpp-4.6-src-windows\omnetpp- 4.6\lib switch to a different build configuration in the project context menu or build the OMNeT++ libraries from the command line. (See the Install Guide for help)."

我想念什么?

1 个答案:

答案 0 :(得分:2)

似乎忘记了x轴的边缘,因为如果缩放,您可以正确看到这些点,那么可能的解决方法是:

plot_ly(data = mydf, x =~Date, y=~a, 
        type = "scatter", mode = "markers", name = 'a', showlegend = TRUE, color = ~b, size =~b) %>%
layout(xaxis = list(range = c(min(mydf$Date), max(mydf$Date))))

enter image description here

或减去最小值,然后将最大值加到最大值,以使边缘上没有最小且第一个x轴点,例如:

plot_ly(data = mydf, x =~Date, y=~a, 
        type = "scatter", mode = "markers", name = 'a', showlegend = TRUE, color = ~b, size =~b) %>%
layout(xaxis = list(range = c(min(mydf$Date)-5000, max(mydf$Date)+5000)))

enter image description here