0

I want to change the group labels in a facet plot in ggplot2. This code

data = tidyr::gather(data = iris, variable, value, -Species)

ggplot(data, aes(y = value, x = variable, fill = Species)) +
  geom_boxplot(position = "dodge", notch = TRUE) +
  ylab("median(x)") +
  facet_wrap(~variable, scales = "free", ncol = 2)

produces enter image description here

I want the x-axis tick labels to represent each Species name instead of the variable the respective sub-plot is being grouped by (which is also repeating whats already in the sub-plots title). Any idea on how I can achieve that? I've been searching the web all over but could not find any valuable information on that.

best regards, Andi

Update

Henrik gave the right answer, I'd have to change the proper aes feature. Thanks!

A. Neumann
  • 488
  • 2
  • 15

0 Answers0