Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ggvis为'添加#u图例;strokeDash';或';冲程宽度';_R_Legend_Ggvis - Fatal编程技术网

ggvis为'添加#u图例;strokeDash';或';冲程宽度';

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

我想对两个变量的数据进行分组,并通过“stroke”和“strokeDash”在ggvis图中区分它们。如果我想向ggvis绘图添加图例,我可以为“stroke”属性添加图例:

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
的图例。我明白了。谢谢你的提示!