Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: how to label the x-axis of a boxplot

Tags:

     apple=c(1,2,3,4,5)      banana=c(5,4,3,2,1)      watermelon=c(4,5,6,7,8)      boxplot(apple, banana, watermelon) 

If I were to plot this, the x-axis of the boxplot is labeled as 1, 2 and 3. How can I change those to "apple", "banana", and "watermelon," respectively? xlab= labels the entire axis, but not the individual boxplots. Which command/option should I use?

like image 314
Adrian Avatar asked Aug 31 '14 05:08

Adrian


1 Answers

If you read the help file for ?boxplot, you'll see there is a names= parameter.

     boxplot(apple, banana, watermelon, names=c("apple","banana","watermelon")) 

enter image description here

like image 200
MrFlick Avatar answered Oct 12 '22 22:10

MrFlick