all Treatment
are in the same bar but I want them separated in a graph Species
wise differentiated by color.
I tried with the below code but it's not separating Treatments
Species Treatment avg_n_roots avg_lng_root avg_dia_root
<chr> <chr> <dbl> <dbl> <dbl>
1 x1 t1 4 7 0.6
2 x1 t2 5 6 0.9
3 x1 t3 4 8 0.7
4 x1 t4 3 6 0.8
5 x2 t1 4 8 0.9
6 x2 t2 5 7 0.3
7 x2 t3 8 8 0.5
8 x2 t4 3 5 0.7
9 x3 t1 4 6 0.3
10 x3 t2 5 5 0.7
11 x3 t3 6 4 0.7
12 x3 t4 9 3 0.8
ths_data_1 |>
tidyr::pivot_longer(c(avg_n_roots, avg_lng_root, avg_dia_root)) |>
ggplot(aes(x = Species, y = value, color = name)) +
geom_col(alpha = 0, position = "dodge") +
facet_wrap(~Species, scales = "free_x") + theme_minimal() +
theme(legend.position = "bottom")
I want my graph to look like this, differentiated for each treatment.