2015-10-14 36 views
0

剪切看起來不會影響barplot() - ??par(xpd)不會剪輯條形圖?

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

線段在y=6修剪,但barplot轉到頁的頂部! 我剛剛在Mac上升級(Fire Safety,3.2.2(2015-08-14));我嘗試使用石英設備,也使用PDF設備 - 同樣的錯誤。如果我使用plot()而不是barplot(),則工作正常。

有沒有其他人有這個錯誤?任何解釋或解決方法?

謝謝!

拉里

回答

2

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) 
+0

謝謝你,加文! - 拉里 – user1040074