0

I want to re-order the bars (fill positions) in my grouped bar plot in ggplot2.

Here is my code for my grouped plot.

data7<-read.csv("inf_size_time.csv")
inf_size_time <- ggplot( data=data7, aes(fill=size, x=Day, y=perc)) +
  geom_bar(position="dodge", stat="identity", width=0.8, 
           colour="black") +
  labs(x="\n Day\n", y= "Percentage\n\n", fill="") +
  ggtitle("a.\n") +
  scale_y_continuous(limits =c(0, 100), breaks = seq(0, 100, 10), 
                       expand = c(0,0)) +
  scale_fill_manual(values = c("rosybrown1", "red1", "red3", "red4"))

inf_size_time

data attached.

I wanted the order of each individual bar in each group (fill position) to be as follows:

<100 μm, ≥100 μm and <500 μm, ≥500 μm and <1000 μm, ≥ 1000 μm

Any ideas on how I can change the order?

enter image description here

enter image description here

kjetil b halvorsen
  • 1,206
  • 2
  • 18
  • 28
D.dot
  • 3
  • 2

0 Answers0