仅在高级图表中显示组

问题描述 投票:0回答:1

我正在使用类似于以下代码的内容来逐组显示条形图:

library(purrr) # map function to make grouped categories argument
library(dplyr) # for select function 

data(mpg, package = "ggplot2")

mpgg <- mpg %>% 
  filter(class %in% c("suv", "compact", "midsize")) %>% 
  group_by(class, manufacturer) %>% 
  summarize(count = n())

categories_grouped <- mpgg %>% 
  group_by(name = class) %>% 
  do(categories = .$manufacturer) %>% 
  list_parse()

highchart() %>% 
  hc_xAxis(categories = categories_grouped) %>% 
  hc_add_series(data = mpgg, type = "bar", hcaes(y = count, color = manufacturer),
                showInLegend = FALSE)

我得到以下图表:

Highchart Group Categories Wise

由于未对齐,我只想显示没有类别的组。我尝试了几种解决方案,但始终存在一些对齐问题。

任何解决方案?

r highcharts data-visualization r-highcharter
1个回答
0
投票
如果您不需要两组类别,则可以像在此JS示例中那样,在不使用grouped-categories.js模块的情况下定义标准类别:jsfiddle.net/BlackLabel/29kgtp3u
© www.soinside.com 2019 - 2024. All rights reserved.