0

使用 LDA 主题模型的结果,我正在尝试创建 30 个水平条形图来显示热门词与其概率。

png("airport.png")
top_terms %>%
  mutate(term = reorder(term, beta)) %>%
  ggplot(aes(term, beta, fill = factor(topic))) +
  geom_bar(stat = "identity", show.legend = FALSE) +
  facet_wrap(~ topic, scales = "free") + 
  coord_flip()
dev.off()

上述代码返回错误:

Error in facet_render.wrap(plot$facet, panel, plot$coordinates, theme,  : 
  ggplot2 does not currently support free scales with a non-cartesian coord or coord_flip.

有什么建议么?

我还尝试了以下方法:

png("airport.png")
top_terms %>%
  mutate(term = reorder(term, beta)) %>%
  ggplot(aes(beta, term, fill = factor(topic))) +
  geom_bar(stat = "identity", show.legend = FALSE) +
  facet_wrap(~ topic, scales = "free")  
  #coord_flip()
dev.off()

输出如下所示。问题是图表不显示水平条。

在此处输入图像描述

4

0 回答 0