I have an issue with my grouped barplots, I want to visualize gene expression, and since some genes had very high expression I decided to se the ylim to different values to better visualize the lower values. However the plots come out looking like this, where the bar marked with 'y' is cut off misleading in the second picture where the limit is set to 5000. Any ideas to why this is and potenitally how to fix it? Ive used this code
grouped_bars <-ggplot(data, aes(x=gene_name, y=Result, fill=Day))+geom_bar(stat="identity",colour="black", position="dodge")+ scale_fill_manual(values =c("blue","red")) + ylim(0, 5000)
Asked
Active
Viewed 31 times
0

user438383
- 5,716
- 8
- 28
- 43

Sara R
- 3
- 1
-
1You could improve your chances of finding help here by adding a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). Adding a MRE and an example of the desired output (in code form, not tables and pictures) makes it much easier for others to find and test an answer to your question. That way you can help others to help you! P.S. Here is [a good overview on how to ask a good question](https://stackoverflow.com/help/how-to-ask) – dario Oct 13 '21 at 10:20
1 Answers
1
Use coord_cartesian()
instead of ylim()
to avoid your bars from getting lost.
grouped_bars <- ggplot(data, aes(x=gene_name, y=Result, fill=Day)) +
geom_bar(stat="identity",colour="black", position="dodge") +
scale_fill_manual(values =c("blue","red")) +
coord_cartesian(ylim=c(0,5000))
grouped_bars

pascal
- 1,036
- 5
- 15