I have multiple variables for which I wish to plot boxplots warpped with facet_wrap. However, when I do this, the individual plots are zoomed out with much of the plot empty. How can I change the x axis range automatically for each variable so each indivual boxplot would be optimized?
Here is the code:
Hist_grid <- data %>% select(-name) %>%
pivot_longer(!type, names_to = "Name", values_to = "Value")
Hist_grid %>% ggplot(aes(x = Value, fill = type)) +
labs(fill = "Cell Type") +
geom_boxplot(notch = T, outlier.shape = NA) + theme_bw() +
facet_wrap(~Name, shrink = T, scales = "free_x")`