Add name to boxplot in R

家住魔仙堡 提交于 2019-12-05 20:16:49

Maybe you can use 'xlab':

boxplot(ddf[,1], xlab="apple")

There is a show.names= argument to bxp, which boxplot calls. You can thus do:

boxplot(ddf[1],show.names=TRUE)

Make sure this is ddf[1] not ddf[,1] though, so that the name is retained.

One way is to use mtext:

boxplot(ddf[,1])
mtext("apple", side=1, line=1)

The boxplot is added at x=1 by default, so you can add at tick and axis label to x=1 as would happen when you plot multiple columns.

axis(side = 1, at = 1, labels = 'apple')

I also used the solution with show.names for Boxplot{car}. In my case I wanted to sum up some columns in one boxplot and label the outliers at the same time, hence I used Boxplot.

Boxplot(df, show.names = T, names = "test samples", labels = rownames(df), id.method = c("y"), id.n=9)

For boxplot you don't need to support a list of names for show.names if you are satisfied with the names of your dataframe. For Boxplot you have to supply a name for the plot.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!