- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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 horizontal lines for each bar in a bar plot of base R?
To create horizontal lines for each bar in a bar plot of base R, we can use abline function and pass the same values as in the original barplot with h argument that represents horizontal with different color to make the plot a little better in terms of visualization.
Example
x<-c(24,25,22) barplot(x) abline(h=c(24,25,22),col="red")
Output
Example2
y<-rpois(5,2) y
Output
[1] 4 0 2 2 4
Example
barplot(y) abline(h=c(4,0,2,2,4),col="blue")
Output
- Related Articles
- How to create empty bar plot in base R?
- How to manually set the color of each bar in base R bar plot?
- How to create a horizontal bar plot using barplot function in R?
- Create bar plot for grouped data of two columns in base R.
- How to create bar plot in base R with different limits for Y-axis?
- How to display x-bar in base R plot?
- How to create stacked bar plot in which each bar sum to 1 or 100% in R?
- How to create a horizontal bar graph using ggplot2 in R?
- How to create a bar plot with bars for missing values in R?
- How to create horizontal stacked bar chart using ggvis in R?
- How to create a bar plot using ggplot2 with one bar having black border in R?
- How to create transparent bar plot using ggplot2 in R?
- How to make a broken horizontal bar plot in Matplotlib?
- How to set the alignment of labels in horizontal bar plot to left in R?
- How to create a bar plot with ggplot2 using stat_summary in R?

Advertisements