par(xpd)不会剪切条形图?

时间:2015-10-14 16:57:30

标签: r clipping

剪辑似乎不会影响barplot() - ??

par(xpd=F); barplot(1:60, ylim=c(0,6)); segments(0,0,200,100, lwd=5)

线段被裁剪为y=6,但条形图会显示在页面顶部! 我刚刚升级了(Fire Safety,3.2.2(2015-08-14)在mac上);我尝试使用石英设备并使用pdf设备 - 同样的错误。如果我使用plot()代替barplot(),则可以正常工作。

有没有其他人有这个错误?任何解释或解决方法?

谢谢!

拉​​里

1 个答案:

答案 0 :(得分:5)

barplot有一个xpd参数,它会覆盖par中的设置。来自?graphics::barplot

## Default S3 method:
barplot(height, width = 1, space = NULL,
        names.arg = NULL, legend.text = NULL, beside = FALSE,
        horiz = FALSE, density = NULL, angle = 45,
        col = NULL, border = par("fg"),
        main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
        xlim = NULL, ylim = NULL, xpd = TRUE, log = "",
        axes = TRUE, axisnames = TRUE,
        cex.axis = par("cex.axis"), cex.names = par("cex.axis"),
        inside = TRUE, plot = TRUE, axis.lty = 0, offset = 0,
        add = FALSE, args.legend = NULL, ...)
     

...

xpd: logical. Should bars be allowed to go outside region?

这适用于,例如,

barplot(1:60, ylim=c(0,6), xpd = FALSE)