R: how to designate the x axis of the rectangle

     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 build this, the x-axis of the boxplot is designated as 1, 2, and 3. How can I change them to apple, banana, and watermelon, respectively? xlab=indicates the entire axis, but not individual boxes. Which command / parameter to use?

+4
source share
1 answer

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

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

enter image description here

+16
source

All Articles