本文介绍了从ggplot2中的facet_grid中删除未使用的因子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个df:

I've this df:

    df <- data.frame(
      id = c(rep(1:3,20), rep(4:6,20)),
      type = rep(c("A","B","C","D"), each=3, times=10),
      timing = rep(c("T0","T1", "T2", "T3", "T4"), each=12, times=2),
      group = rep(c("Case","Control"),each=60),
      percentage = runif(120, min=15, max=25)
    )

scale =free scale =free_y $ b

scale="free" or scale="free_y" dosen't work producing this bar plot:

  require(scales)
   ggplot(df, aes(x=id, y=percentage, fill=type)) +
   facet_grid(group ~ timing,scale="free") +
   geom_bar(position="stack",aes(width = 0.5),stat = "identity") +
   scale_y_continuous(labels = percent_format())+
   coord_flip()

推荐答案

这个问题没有解决方案?我在阅读那个faces_grid不支持 drop droplevels scale

No solutions for this issue? I was reading that faced_grid doesn't supports drop, droplevels, scale.

真的吗?

这篇关于从ggplot2中的facet_grid中删除未使用的因子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 03:52