【问题标题】:ggvis - adjust legend color to fill colorggvis - 调整图例颜色以填充颜色
【发布时间】:2016-05-19 19:21:57
【问题描述】:

以下代码生成填充颜色从红色到黄色的标记。 然而,默认图例具有蓝色光谱。

library(ggvis)
mtcars %>% 
ggvis(~wt, ~mpg, fill = ~disp, stroke = ~disp, strokeWidth := 2) %>%
layer_points() %>%
scale_numeric("fill", range = c("red", "yellow")) %>% 
add_legend("fill", orient = 'left')

如何删除右上角的默认文件?

【问题讨论】:

    标签: r legend ggvis


    【解决方案1】:

    默认图例为stroke,您的自定义图例为fill。如果您在ggvis 行中将stroke 设置为"black",则右侧的图例将消失。

    ...ggvis(~wt, ~mpg, fill = ~disp, stroke := "black", strokeWidth := 2) %>% ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-12
      • 2010-10-29
      相关资源
      最近更新 更多