简体   繁体   中英

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

     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?

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"))

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM