5
用par(fig)
設置圖形參數並使用原始參數重置它們後,繪圖邊距中的文本不會寫入。 只有在內之後的另一個低級別命令執行繪圖區域將執行它將再次工作。這裏有一個例子:par(fig)後,不寫入邊距文本
dev.off()
plot(1:10)
op <- par(no.readonly = TRUE)
mtext("hello", adj=1, col=2) # written as expected
par(fig=c(0.1,0.6,0.5,0.8), new=TRUE)
par(op)
mtext("hello ", adj=1, col=3) # not written
mtext("hello ", adj=1, col=3, line=-1) # works inside plot region
mtext("hello ", adj=1, col=3) # still not written
text(50,20,"") # or abline # do something inside plot region
mtext("hello ", adj=1, col=3) # now it works!
這可能涉及到另外一個問題,我張貼after par(fig), mtext is slightly off下。
除了mtext
,axis
也不起作用。除了text/abline/points
,title(main="dummy")
也解決了這個問題。
這可能是一個R bug?或者我錯過了什麼?
我懷疑par(op)'開始一個新的情節。將'par(op)'替換爲'par(fig = op $ fig,new = TRUE)',它按預期工作。 –
現在很有趣! 'par(fig = op $ fig)'沒有'new'就足夠了,順便說一下..這並不能解釋它爲什麼在繪圖區域工作,但不在邊緣,儘管...... –