Skip to content

Axes labels are not properly placed when combining faceted and single plots #422

Open
@eggrandio

Description

@eggrandio

I am combinining four plots, two of them have facets and two of them are single plots. They all have the same y axes.

When I arrange them, the y axes labels of the single plots are not placed properly, and they have extra padding:

Image

Here is the code I have used:

faceted_plot<-
  ggplot(input_data, aes(x = Line, y = indel, fill = gene)) +
  geom_bar(position = "dodge", stat = "identity") +
  scale_y_continuous(expand = expansion(mult = c(0, 0))) +
  scale_fill_manual(values = wes_palette("GrandBudapest1")[1:2])
  facet_grid(~Plasmid, 
             scales = "free_x", 
             space = "free", 
             switch = "x") +
  labs(y = "% indel",
       fill = "Gene") +
  theme(legend.justification = "left", strip.placement = "outside",
        strip.background = element_blank(),
        axis.title.x = element_blank())

single_plot <-
  ggplot(input_data2, aes(x = Line, y = indel, fill = gene)) +
  geom_bar(position = "dodge", stat = "identity") +
  scale_y_continuous(expand = expansion(mult = c(0, 0))) +
  scale_fill_manual(values = wes_palette("GrandBudapest1")) +
  labs(y = "% indel",
       fill = "Gene") +
  theme(legend.justification = "left")

final_plot <- faceted_plot1 / faceted_plot2 / single_plot1 / single_plot2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions