- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a barplot with gaps on Y-axis scale in R?
If we want to have gaps on Y-axis scale in a barplot then it cannot be done in base R. For this purpose, we can make use of gap.barplot function of plotrix package. The gap.barplot function is very handy, we just need to pass the vector for which we want to create the barplot and the gap values simply by using gap argument.
Loading plotrix package:
> x<-rpois(20,5) > x
 2 6 5 4 7 2 5 2 5 2 8 6 8 13 3 5 7 7 5 6
> gap.barplot(x,gap=c(2,4)) ylim 0 11
In gap.barplot(x, gap = c(2, 4)) : gap includes some values of y
> y<-sample(0:50,10) > y
 8 50 45 35 25 12 40 41 14 32
> gap.barplot(y,gap=c(20,30)) ylim -2 40
In gap.barplot(y, gap = c(20, 30)) : gap includes some values of y
- How to create a bar plot using ggplot2 with percentage on Y-axis in R?
- Create ggplot2 graph with reversed Y-axis and X-axis on top in R.
- How to create stacked barplot using barplot function in R?
- How to create cumulative sum chart with count on Y-axis in R using ggplot2?
- How to exponentially scale the Y axis with matplotlib?
- How to create a plot with reversed Y-axis labels in base R?
- Create stacked bar chart with percentages on Y-axis using ggplot2 in R.
- How to create stacked barplot using barplot function with each bar having unique color in R?
- How to plot values with log scales on x and y axis or on a single axis in R?
- How to create facetted scatterplot with scale of X-axis based on the numerical values corresponding to grouping column in R?
- How to create a histogram with Y-axis values as count using ggplot2 in R?
- How to align the bars of a barplot with the X-axis using ggplot2 in R?
- How to create bar plot in base R with different limits for Y-axis?
- How to create a plot in base R with dates sequence on X-axis?
- How to create a barplot with one of the bars having different color in R?