简体   繁体   English

facet_wrap / facet_grid 在 highcharter 中有任何类似的功能吗?

[英]Facet_wrap / facet_grid any similar function in highcharter?

I have the below data frame and plotting has done with ggplot..is there any similar function like facet_grid or facet_wrap in highcharter我有下面的数据框,绘图已经用 ggplot 完成了..在 highcharter 中是否有类似facet_gridfacet_wraphighcharter

df1<-data.frame(
      Year=sample(2016:2018,100,replace = T),
      Month=sample(month.abb,100,replace = T),
      category1=sample(letters[1:6],100,replace = T),
      catergory2=sample(LETTERS[8:16],100,replace = T),
      lic=sample(c("P","F","T"),100,replace = T),
      count=sample(1:1000,100,replace = T)
    )

Plot code:剧情代码:

ggplot(df1,aes(Year,count,fill=factor(lic))) +
      geom_bar(stat = "identity",position = "stack") +
      facet_grid(~category1)

输出

The best what I found is this.我发现的最好的是这个。

df2 <- df1 %>% 
  group_by(Year,category1  ,lic) %>% 
  summarise(count=sum(count)) 
map(unique(df2$category1), function(x){
  df2 %>% filter(category1 == x) %>% 
    hchart(., "column", hcaes(x = Year, y = count, group = lic),showInLegend = FALSE) %>% 
    hc_plotOptions(column = list(stacking = "normal")) %>% 
    hc_add_theme(hc_theme_smpl()) %>% 
    hc_title(text = x) %>% 
    hc_yAxis(title = list(text = ""))
  }) %>% 
  hw_grid(rowheight = 150) %>% htmltools::browsable()

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM