2016-09-06 78 views

回答

1

你可以计算使用compute_count酒吧和文本数据集。这很像ggvis basics docs中的compute_bin示例。

获取文本对齐需要一些工作,请参阅this question/answer根据this open github issue

mtcars %>% 
    compute_count(~factor(cyl)) %>% 
    ggvis(x = ~x_, y = ~count_) %>% 
    layer_bars(fill = ~x_) %>% 
    layer_text(text := ~x_, prop("x", ~x_, scale = "xcenter"), y = ~count_ + .5, 
      fontSize := 18, align := "center") %>% 
    scale_nominal("x", name = "xcenter", padding = .9, points = TRUE) 

enter image description here

+0

@userJT这是不是回答你的问题? – aosmith