将名称添加到R中的箱线图 [英] Add name to boxplot in R
本文介绍了将名称添加到R中的箱线图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此问题与以下内容有关: R:如何标记箱形图的x轴
This question is related to: R: how to label the x-axis of a boxplot
绘制多列时,将显示名称。但是当只绘制一列时,即使使用names = ..参数,名称也不会出现:
When more than one column is plotted, names appear. But when only one column is plotted, name does not appear, even when names=.. argument is used:
ddf = structure(list(apple = c(1, 2, 3, 4, 5), banana = c(5, 4, 3,
2, 1), watermelon = c(4, 5, 6, 7, 8)), .Names = c("apple", "banana",
"watermelon"), row.names = c(NA, -5L), class = "data.frame")
ddf
apple banana watermelon
1 1 5 4
2 2 4 5
3 3 3 6
4 4 2 7
5 5 1 8
boxplot(ddf[,1:2])
boxplot(ddf[,1])
以下操作也不起作用:
boxplot(ddf[,1], names='apple')
boxplot(ddf[,1], names=c('apple'))
如何当仅使用一列时,我在箱图中添加名称吗?谢谢您的帮助。
How can I add name to the boxplot when only one column is used? Thanks for your help.
推荐答案
也许您可以使用'xlab':
Maybe you can use 'xlab':
boxplot(ddf[,1], xlab="apple")
这篇关于将名称添加到R中的箱线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文