ggvis为'添加#u图例;strokeDash';或';冲程宽度';
我想对两个变量的数据进行分组,并通过“stroke”和“strokeDash”在ggvis图中区分它们。如果我想向ggvis绘图添加图例,我可以为“stroke”属性添加图例:ggvis为'添加#u图例;strokeDash';或';冲程宽度';,r,legend,ggvis,R,Legend,Ggvis,我想对两个变量的数据进行分组,并通过“stroke”和“strokeDash”在ggvis图中区分它们。如果我想向ggvis绘图添加图例,我可以为“stroke”属性添加图例: library(ggvis) mtcars %>% ggvis(~wt, ~mpg, stroke = ~factor(cyl), strokeDash = ~factor(vs)) %>% layer_lines() %>% add_legend('stroke', title = '
library(ggvis)
mtcars %>%
ggvis(~wt, ~mpg, stroke = ~factor(cyl), strokeDash = ~factor(vs)) %>%
layer_lines() %>%
add_legend('stroke', title = 'Number of cylinders')
但是,如果尝试为“strokeDash”添加图例,则不会渲染绘图:
mtcars %>%
ggvis(~wt, ~mpg, stroke = ~factor(cyl), strokeDash = ~factor(vs)) %>%
layer_lines() %>%
add_legend('stroke', title = 'Number of cylinders') %>%
add_legend('strokeDash', title = 'V/S')
如果我尝试使用“strokeWidth”而不是“strokeDash”,同样适用:
# works
mtcars %>%
ggvis(~wt, ~mpg, stroke = ~factor(cyl), strokeWidth = ~factor(vs)) %>%
layer_lines() %>%
scale_nominal('strokeWidth', range = c(1,5)) %>%
add_legend('stroke', title = 'Number of cylinders')
# does not work
mtcars %>%
ggvis(~wt, ~mpg, stroke = ~factor(cyl), strokeWidth = ~factor(vs)) %>%
layer_lines() %>%
scale_nominal('strokeWidth', range = c(1,5)) %>%
add_legend('stroke', title = 'Number of cylinders')%>%
add_legend('strokeWidth', title = 'V/S')
有人知道为什么“中风”有效,而对其他人无效吗?有什么解决办法吗
谢谢,
Fabian基于这个开放,看起来您目前可能无法拥有
strokeDash
的图例。我明白了。谢谢你的提示!