- Related Questions & Answers
- How to create a plot with reversed Y-axis labels in base R?
- How to create a bar plot using ggplot2 with percentage on Y-axis in R?
- Automatically setting Y-axis limits for a bar graph using Matplotlib
- How to create empty bar plot in base R?
- How to create horizontal lines for each bar in a bar plot of base R?
- How to create different Y-axis for group levels using ggplot2 in R?
- How to create a plot in base R with dates sequence on X-axis?
- How to create a plot with tick marks between X-axis labels in base R?
- How to change the Y-axis values in a bar plot using ggplot2 in R?
- How to create a bar plot with bars for missing values in R?
- How to create gridlines that matches with Y-axis values in the plot created by using plot function in R?
- How to create a barplot with gaps on Y-axis scale in R?
- How to create a plot with dashed regression line in base R?
- How to create plot in R with different shape of points?
- How to create a plot in base R without margins?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

To create a bar plot in base R with different limits for Y-axis, we can use ylim argument but generally that behaves badly, such as extending the bars below X-axis. Therefore, we need to fix those things. Check out the below example to understand how it can be done.

> x<-c(501,324) > barplot(x)

> barplot(x,ylim=c(300,600))

> barplot(x,ylim=c(300,600),xpd=FALSE)

> box(bty="l")

Advertisements