Skip to content

ggplot2: removing empty factor levels in facet_grid

2 messages · Anna Zakrisson Braeunlich, Ista Zahn

#
Hi Anna,

It's unclear what you want here, as it doesn't make sense in this
example to remove the empty panels. Doing so will mess up the
alignment of the remaining panels. Perhaps you want

ggplot(mydata,aes(week,values))+
  facet_wrap(~year+station, scales = "fixed", drop=TRUE)+
  scale_shape_manual(values = 1:3) +
  geom_point(mapping=aes(shape=factor(organism)))+
  theme_bw() +
  theme(strip.background = element_blank()) +
  ggtitle("this plot is ugly but ignore that")+
  xlab("my x-axis stuff")+
  ylab("my y-axis stuff")+
  theme(legend.title=element_blank(), legend.key =
          element_blank())

?

Note also that there is a separate ggplot2 mailing list at
https://groups.google.com/forum/#!forum/ggplot2 -- you may wish to
post ggplot2-related questions there in the future.

Best,
Ista

On Mon, Feb 3, 2014 at 6:54 AM, Anna Zakrisson Braeunlich
<anna.zakrisson at su.se> wrote: