How do you order the fill-colours within ggplot2 geom_bar
1
0
Entering edit mode
2.9 years ago
j_weld ▴ 10

I am calling the ggplot function

ggplot barplot R • 4.9k views
ADD COMMENT
0
Entering edit mode

j_weld : Please do not delete posts once they have received comments/answer. If the answer solved your problem appropriate way to acknowledge the help is to accept the answer (green check mark).

ADD REPLY
0
Entering edit mode
2.9 years ago

You need to set the factor order for the Genus variable.

level_order <- c("Gilliamella", "Snodgrassella", "Bifidobacterium", "Lactobacillus", "Frischella")
data$Genus <- factor(data$Genus, levels=level_order)

The order might be backwards with the above code. If so change fill=Genus to fill=forcats::fct_rev(Genus) in your ggplot command.

ADD COMMENT

Login before adding your answer.

Traffic: 1378 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6