- 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 a horizontal bar plot using barplot function in R?
To create a bar plot in base R, we can directly use barplot function but the table of frequencies should be passed inside this function. If we want to create the barplot in horizontal manner then horiz=TRUE argument must be added. For example, if we have a vector x that contains repeating values then the horizontal bar plot of x can be created by using barplot(table(x),horiz=TRUE).
Example1
> x<-rpois(50,2) > barplot(table(x),horiz=TRUE)
Output
Example2
> y<-rpois(500,2) > barplot(table(y),horiz=TRUE)
Output
Example3
> z<-sample(0:5,5000,replace=TRUE) > barplot(table(z),horiz=TRUE)
Output
- Related Articles
- How to create varying width bar chart using barplot function in R?
- How to create stacked barplot using barplot function with each bar having unique color in R?
- How to create stacked barplot using barplot function in R?
- How to create horizontal lines for each bar in a bar plot of base R?
- How to create a horizontal bar graph using ggplot2 in R?
- How to create horizontal stacked bar chart using ggvis in R?
- How to create transparent bar plot using ggplot2 in R?
- How to create a bar plot with ggplot2 using stat_summary in R?
- How to create a plot in R with gridlines using plot function?
- How to create a bar plot using ggplot2 with one bar having black border in R?
- How to show all X-axis labels in a bar graph created by using barplot function in R?
- How to create bar plot with log values using ggplot2 in R?
- How to create a plot in R with a different plot window size using plot function?
- How to create empty bar plot in base R?
- How to create a stacked bar plot with vertical bars in R using ggplot2?

Advertisements