I would like to recreate this plot:
My data looks like this:
leafnumber <- c(6,7,8,9,6,7,8,9)
PU <- c(30,15,7,0,10,36,7,9)
weeknumber <- c(8,8,8,8,9,9,9,9)
df <- data.frame(leafnumber, PU, weeknumber)
So I want leafnumber to end up on the Y-axis and PU on the X-axis. And weeknumber can be used to show distribution over time.
Here is my first attempt:
ggplot(df,aes(leafnumber, PU)) +
geom_bar(stat = "identity") +
coord_flip()
I am not sure how to get from a bar plot to a 'grouped' barplot, like the one in the image.
The goal is to have this distribution for each weeknumber on the X-axis so I can see the distribution change within time.
What I do not mean is this:
ggplot(df,aes(leafnumber, PU, fill=weeknumber)) +
geom_bar(stat = "identity") +
coord_flip()
Any suggestions/solutions for this problem would be appreciated.

