为什么我的ggplot条位于两个单独的网格上?

问题描述

这来自an online example on Hidden Markov Models。 有代码

  library(ggplot2)
    library(gridExtra)
    library(reshape2)
   
 ggplot(hmm1$draws,aes(x = as.numeric(roll),y = state,fill = state,col = state)) +  
      geom_bar(stat = "identity",alpha = I(0.7))  +
      scale_fill_manual(values = mycols,name = "State:\nPerson that\nrolled the\ndice",labels = c("Alice","Bob")) +
      scale_color_manual(values = mycols,"Bob")) +
      theme(axis.ticks = element_blank(),axis.text.y = element_blank()) +
      labs(y = "Actual State")

他们应该在下面产生这种结果

enter image description here

但是我发现这些条形图是“重叠的”,位于两条单独的线上

enter image description here

我不知道这是否取决于编码(我尝试了不同的选项,但未更改)或R上设置的某些参数。有什么建议吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)