我正在使用类似于以下代码的内容来逐组显示条形图:
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
由于未对齐,我只想显示没有类别的组。我尝试了几种解决方案,但始终存在一些对齐问题。
任何解决方案?