我有一些数据
theData <- structure(list(matter_date = structure(c(16921, 16940, 16941,
16944, 16947, 16976, 17013, 16921, 16976, 17013, 16921, 17013,
16921, 16944, 16947, 16976, 17013, 16944, 17013, 16921, 16921,
16941, 16976, 17013, 16921, 17013, 16921, 16940, 16976, 17013,
16921, 16941, 16976, 16921, 16976, 17013, 16921, 16944, 16976,
17013, 16921, 16940, 16941, 16944, 16947, 16976, 17013), class = "Date"),
variable = c("meanOfMeans", "meanOfMeans", "meanOfMeans",
"meanOfMeans", "meanOfMeans", "meanOfMeans", "meanOfMeans",
"Dude1", "Dude1", "Dude1", "Dude2", "Dude2", "Dude4", "Dude4",
"Dude4", "Dude4", "Dude4", "Dude5", "Dude5", "Dude6", "Dude7",
"Dude7", "Dude7", "Dude7", "Dude8", "Dude8", "Dude9", "Dude9",
"Dude9", "Dude9", "Dude10", "Dude10", "Dude10", "Dude11",
"Dude11", "Dude11", "Dude12", "Dude12", "Dude12", "Dude12",
"Regression", "Regression", "Regression", "Regression", "Regression",
"Regression", "Regression"), value = c(72.767610875949, 90.9392641619622,
45.7405729014483, 85.7259119652673, 105, 80.312242735507,
81.5089081756173, 62.0696399467241, 59.462122627886, 83.855246493738,
103.75, 102.42032111191, 89.9205770857696, 98.1040118882406,
105, 88.9856689007873, 94.4812947992748, 59.0737240075614,
63.3163826710261, 79.174945478451, 55.7207891785418, 46.0817358331578,
81.4596142685542, 77.1262273117138, 60.4308669614855, 61.3321478799418,
89.9425197232886, 90.9392641619622, 85.916058394926, 89.1779327977449,
59.9003207762254, 45.3994099697388, 68.9847172646122, 46.8048325311855,
93.4687872124697, 79.4732085405457, 79.9616170778186, 100,
83.9087304793132, 82.3974119746606, 80.565164208156, 80.7257268243583,
80.734177488369, 80.7595294804009, 80.7848814724329, 81.0299507287417,
81.3426252971356), thickness = c(1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4,
4)), .Names = c("matter_date", "variable", "value", "thickness"
), class = c("data.table", "data.frame"), row.names = c(NA, -47L)
)
可以用
绘图 plot_ly(theData, x = ~matter_date, y = ~value, color = ~variable, colors =RColorBrewer::brewer.pal(12, "Set3"), type = "scatter", mode = "lines") %>%
layout(
title = "Realization",
xaxis = list(rangeslider = list(type = "date")),#,
yaxis = list(title = "Realization Average%",
range = c(0,105)
)
)
但是我想让厚度列确定线条的粗细。 这可能吗?
答案 0 :(得分:0)
plot_ly(theData, x = ~matter_date, y = ~value, color = ~variable, colors
=RColorBrewer::brewer.pal(12, "Set3"), type = "scatter", mode = "lines",
line=list(width=~thickness)) %>%
layout(
title = "Realization",
xaxis = list(rangeslider = list(type = "date")),#,
yaxis = list(title = "Realization Average%",
range = c(0,105)
)
)
我遇到了同样的问题,这是我遇到的解决方案。希望它有帮助:)