teunbrand / ggh4x

ggplot extension: options for tailored facets, multiple colourscales and miscellaneous
https://teunbrand.github.io/ggh4x/
Other
534 stars 32 forks source link

Separate nested facet wraps #62

Closed andhamel closed 2 years ago

andhamel commented 2 years ago

Hello,

Consider the toy example:

df2 <- data.frame(tissue = c("Blood", "Nerve", "Stomach", "Liver", "Blood", "Kidney"),
                  qtl = c("e", "s", "e", "e", "s", "s"),
                  gene = c("gene1", "gene1", 
                           "gene2", "gene2",
                           "gene3", "gene4"),
                  value = c(0.4, 0.2, 0.1, 0.9, 0.5, 0.3),
                  second_label = c("label1", "label1", "label1","label1",
                                  "label2", "label2"))

And I plot it as such:

ggplot(df2, aes(x=tissue, y=qtl, size=value))+
  geom_point()+
  facet_nested(second_label + gene ~ ., switch="y") +

  theme(axis.title.x = element_blank(),
        axis.text.x = element_text(size=8,angle = 90, hjust=1, vjust=0.2),
        axis.title.y = element_blank(),
        axis.text.y = element_text(size=8),
        axis.ticks.y = element_blank(),
        axis.line = element_line(color = "black"),
        strip.text.y.left = element_text(size = 8, angle=0),
        strip.background = element_rect(fill='white', color="black"),
        panel.spacing.y = unit(0.5, "lines"),
        strip.placement = "outside",
        panel.background = element_blank(),
        panel.grid.major = element_line(colour = "#ededed", size = 0.5))
original1

However, is it possible to break up the facet wraps? Where the "gene" facet remain on the left side and I move the "second_label" facets to the right?

teunbrand commented 2 years ago

Hi there,

This is currently not possible with {ggh4x}. It might be possible once I get around to #57, but so far I haven't found the will to work on that yet.

andhamel commented 2 years ago

Makes sense! I can imagine it would be quite intensive. In any case, great package! It saved me a lot of headache

teunbrand commented 2 years ago

I'll be closing this issue in favour of the earlier one.