0

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")`

Here is the current plot

Harrison Jones
  • 2,256
  • 5
  • 27
  • 34
  • It will be easier to help if you provide the data that is in your `data` object. [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Harrison Jones Apr 19 '23 at 16:17

0 Answers0