ggplot make boxplots more wide
0
0
Entering edit mode
4 months ago
Nona ▴ 90

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 • 1.0k views
ADD COMMENT
1
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

geom="point" to make it a dot.

ADD REPLY
1
Entering edit mode

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

What is in metadata ?

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode

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))

ADD REPLY
0
Entering edit mode

Thank you everyone.

ADD REPLY

Login before adding your answer.

Traffic: 3932 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