1

如何复制我的 x 轴(在 y 中变为 y type='bar'?),所以我将它们都放在顶部和底部?

例子:

library(dplyr)
library(ggplot2)
library(highcharter)
mpgg <- mpg %>% 
  filter(class %in% c("suv", "compact", "midsize")) %>% 
  add_row(manufacturer="loner",class="newClass")%>%
  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)

在此处输入图像描述

4

0 回答 0