簡體   English   中英

facet_wrap / facet_grid 在 highcharter 中有任何類似的功能嗎?

[英]Facet_wrap / facet_grid any similar function 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)
    )

劇情代碼:

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

輸出

我發現的最好的是這個。

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