- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 change the X-axis labels for boxplots created by using boxplot function in R?
When we create boxplots for multiple categories in R using boxplot function, by default the X-axis labels are represented by numbers. But we might want to express the categories by their name. In this situation, we can use names argument along with the boxplot function.
Consider the below vectors that represent different categories and create the boxplot for these categories −
Example
Class1<-sample(101:200,1000,replace=TRUE) Class2<-sample(150:200,1000,replace=TRUE) Class3<-sample(180:200,1000,replace=TRUE) Class4<-sample(190:200,1000,replace=TRUE) boxplot(Class1,Class2,Class3,Class4)
Output
Now create the boxplot for the above categories by displaying their names on the X-axis −
Example
boxplot(Class1,Class2,Class3,Class4,names=c("Class1","Class2","Class3","Class4"))
Output
Example
boxplot(Class1,Class2,Class3,Class4,names=c("Class_I","Class_I","Class_III","Class_IV"))
Output
- Related Articles
- How to change the Y axis limit for boxplot created by using ggplot2 in R?
- How to apply manually created x-axis labels in a histogram created by hist function in R?
- How to reverse the X-axis labels of scatterplot created by using ggplot2 in R?
- How to show all X-axis labels in a bar graph created by using barplot function in R?
- How to display mean inside boxplot created by using boxplot function in R?
- How to create a boxplot using ggplot2 for single variable without X-axis labels in R?
- How to change ordinal X-axis label to text labels using ggplot2 in R?
- How to remove outliers from multiple boxplots created with the help of boxplot function for columns of a data frame using single line code in R?
- How to change the color and size of the axes labels of a plot created by using plot function in R?
- How to change the orientation and font size of x-axis labels using ggplot2 in R?
- How to display positive sign for X-axis labels in R using ggplot2?
- How to change the axes labels using plot function in R?
- How to use mtext function to create the X-axis labels in base R?
- How to change the gridlines of Y-axis on a chart created by using ggplot2 in R?
- How to increase the X-axis labels font size using ggplot2 in R?

Advertisements