par(xpd) 不剪辑条形图?

par(xpd) does not clip barplots?

剪裁似乎没有影响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().

,效果很好

还有其他人遇到这个错误吗?任何解释或解决方法?

谢谢!

拉里

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)