【问题标题】:Boxplot missing label箱线图缺少标签
【发布时间】:2014-06-21 05:18:57
【问题描述】:

boxplot(smkgp, nsmkgp, main="premature delivery", xlab="gestation", ylim=c(200,400), xlim=c(0,3), horizontal=TRUE, names=c("smoking group", "nonsmoking group"))

我在做一个箱线图,要显示两组:吸烟组和非吸烟组。

但不吸烟组的标签不见了。 我尝试使用 par(mar(,,,,) 来显示缺少的标签,但它不起作用。

我该如何解决这个问题?

感谢您的宝贵时间。

【问题讨论】:

  • 添加las = 1;你可能还需要弄乱mar设置,试试par(mar = c(4,8,4,2))(我将左边距增加到8行)

标签: r boxplot


【解决方案1】:

R 不会打印第二个标签,因为它们会重叠。您可以考虑关闭默认的 y 轴(使用 yaxt="n")并绘制文本并旋转标签(使用 axis()las=2)。请务必在左边距添加填充,以便为标签腾出空间。

par(mar=c(5,10,4,2)+.1)
boxplot(runif(100),runif(100,.5,1.5), main="premature delivery", 
    xlab="gestation", xlim=c(0,3), 
    horizontal=TRUE, 
    yaxt="n"
)
axis(2, labels=c("smoking group", "nonsmoking group"), at=1:2, las=2)

【讨论】:

    猜你喜欢
    • 2021-01-14
    • 2013-10-23
    • 1970-01-01
    • 1970-01-01
    • 2020-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-21
    相关资源
    最近更新 更多