boxplots with high and low values

19 Views Asked by At

I have the following example data:

data <- data.frame(
  Sample = rep(c("Sample1", "Sample2", "Sample3"), each = 12),
  Trait = rep(c("Trait1", "Trait2", "Trait3", "Trait4"), times = 9),
  Value = c(rnorm(12, mean = 1, sd = 0.5), rnorm(12, mean = 25, sd = 5), rnorm(12, mean = 10, sd = 6)),
  Tissue = rep(c("Tissue1", "Tissue2", "Tissue3"), each = 12)
)

"Tissue1" has way lower values than the others. In the example plot, it looks like this:

data_means <- data %>%
  group_by(Trait, Tissue) %>%
  summarize(Avg = mean(Value, na.rm = TRUE))

ggplot() +
  geom_boxplot(data = data, aes(x = Tissue, y = Value, fill = Tissue)) +
  geom_point(data = data_means, aes(x = Tissue, y = Avg, group = Trait), size = 3, color="darkred") +
  geom_line(data = data_means, aes(x = Tissue, y = Avg, group = Trait), size = 1,color="darkred") +
  facet_wrap(~Trait, scales = "free") +
  theme_minimal()

enter image description here

The boxplot for "Tissue1" is therefore difficult to see. I know, that one option would be to use log10 on the y axis, but I want to explore other options before. Maybe there are some other creative ideas? Other packages are also welcome.

0

There are 0 best solutions below