I would need to modify the aspect of my legend.
I have this R code and this plot :
rr <- tribble( ~zone, ~type, ~station, ~species, ~number, 'A1', 'Adult', 1, 'Atlanticus', 2, 'A1', 'Adult', 1, 'Olrikii', 1, 'A1', 'Larvae', 2, 'Medius', 5, 'A2', 'Larvae', 1, 'Glacialis', 7, 'A2', 'Larvae', 2, 'Unidentified', 3, 'A2', 'Adult', 2, 'Glacialis', 2, 'A2', 'Larvae', 2, 'Medius', 4, 'A3', 'Zoo', 1, 'Capilatta', 17, 'A3', 'Adult', 3, 'Olrikii', 1 ) rr %>% group_by(zone) %>% mutate(Percent = 100 * number/sum(number)) %>% ggplot(aes(zone, y = Percent, fill = species)) + geom_col(position = "dodge")
Created on 2022-06-07 by the reprex package (v2.0.1)
What I want to do it's :
- Change the display order of my legend to have a descending order, i.e. have my most abundant species first etc.
- Finally I would also like to be able to display for example only the 3 most abundant species (and always in descending order).
And a little bonus if anyone ever knows how to do it, it would be to color my station names (in x) with respect to the Area column
I've searched several forums and couldn't find anything to do this.