绘制多个变量进行比较

时间:2018-11-06 16:18:28

标签: r ggplot2 lubridate

在比较以下数据的不同参数时,绘制多个变量的最佳方法是什么

   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)

presently generated but i still needed another one

1 个答案:

答案 0 :(得分:1)

您可能正在寻找用facet_grid(~category1)替换facet_grid(category1~Month)

enter image description here