
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 show all X-axis labels in a bar graph created by using barplot function in R?
In base R, the barplot function easily creates a barplot but if the number of bars is large or we can say that if the categories we have for X-axis are large then some of the X-axis labels are not shown in the plot. Therefore, if we want them in the plot then we need to use las and cex.names.
Example
Consider the below data and bar graph −
> x<-sample(1:5,20,replace=TRUE) > names(x)<-rep(c("IN","CO","LA","NY"),times=5) > barplot(x)
Output
Showing all the X-axis labels −
> barplot(x,las=2,cex.names=0.5)
Output
- Related Questions & Answers
- How to apply manually created x-axis labels in a histogram created by hist function in R?
- How to change the X-axis labels for boxplots created by using boxplot function in R?
- How to reverse the X-axis labels of scatterplot created by using ggplot2 in R?
- How to display long X-axis labels in a bar chart using plotly in R?
- How to create a horizontal bar plot using barplot function in R?
- How to rotate X-axis tick labels in Pandas bar plot?
- 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 a dendrogram without X-axis labels in R?
- How to use mtext function to create the X-axis labels in base R?
- How to change the bars color to grey shade of a bar graph created by using ggplot2 in R?
- How to align the bars of a barplot with the X-axis using ggplot2 in R?
- How to change the title of a graph to italic created by using plot function in R?
- How to display positive sign for X-axis labels in R using ggplot2?
Advertisements