This is a test version of Biostars. For the public version, visit https://www.biostars.org.
ggplot make boxplots more wide

Good afternoon,

Could anyone advice me on how to to make the boxplot more wide so that you can actually see the colour of the legend?

Current plot:

enter image description here

Current code:

ggplot(data = metadata, aes(x=location, y=gene)) + geom_boxplot(aes(fill=Day),show.legend = TRUE)

Thank you very much!

ggplot2 r

If there is no interquartile range in the data then you cannot magically create it. Consider maybe stat_summary(aes(color=Day), geom="line", fun = mean) to plot a line for the mean.

geom="point" to make it a dot.

If you have 1 value for each location/day, you will get a line. Prefer just plotting a dot.

What is in metadata ?

Yes its actually just one sample per location / day. Location is e.g. lung and liver and day is day 1,2,3 and gene is gene expression for this location/day.

How can I change it to a dot instead of a line?

Set colour to Day as well:

ggplot( data = metadata, aes(x = location, y = gene, fill = Day, colour = Day)) +  geom_boxplot()

To get more specific answer, please provide example data: dput(head(mydata, 10))

Thank you everyone.

0 answers

No answers yet.

Log in to answer this question.