如何将值放在中位数,第一四分位数和最后四分位数的箱线图中? [英] How to put values on a boxplot for median, 1st quartile and last quartile?

查看:216
本文介绍了如何将值放在中位数,第一四分位数和最后四分位数的箱线图中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Boxplot上放置值并控制其宽度?

How to put values on boxplot and control its width?

X<-c(1,2,,3,4,4,5,5,6,6,6,6,6,7)

我需要为min,max,第一四分位数,中位数和最后四分位数。我怎么把它放在那里?

I need to write values for min, max, 1st quartile, median and last quartile. How can I put it there?

推荐答案

您可以使用 horizo​​ntal = TRUE 获取水平箱线图,并使用 axes = FALSE 删除轴。 staplewex = 1 将装订宽度设置为与盒子宽度相同

You can use horizontal = TRUE get a horizontal boxplot and axes = FALSE to remove the axes. staplewex = 1 sets the staple width the same as the box width

然后可以使用 fivenum 返回用于创建箱线图的统计信息并将其用作文本标签,摆弄 y 值,直到获得所需的内容

Then you can use fivenum to return the statistics used to create the boxplot and use these as text labels, fiddling with the y value until you have what you want

boxplot(X, horizontal = TRUE, axes = FALSE, staplewex = 1)
text(x=fivenum(X), labels =fivenum(X), y=1.25)

请注意,我插入了 3 表示示例数据 X

Note that i've inserted a 3 for the value missing in your example data X

这篇关于如何将值放在中位数,第一四分位数和最后四分位数的箱线图中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆