1

I am trying to make a chart in R that has a U box around the figure (lines on the bottom, left, and right but nothing up top). For some reason, I always end up with a complete box. Sample code:

x11()
par(fig = c(.1,.9,.1,.9), plt = c(.1,.5,.1,.9), bty = "u")
plot(c(1,2,3),c(1,2,3))
par(fig = c(.1,.9,.1,.9), plt = c(.5,.9,.1,.9), bty = "u", new =TRUE)
plot(c(1,2,3),c(1,2,3))
box("figure", bty = "u")

The result has the plot properly taking up half the figure and a box around the whole figure, however the box has all four sides.

Any idea what is happening?

Edit for clarification: Sorry if this wasn't clear, but I'm not worried about putting a box around the one plot. I will eventually have two plots next to each other and I would like one U box surrounding them both. I have also edited the example code.

4

1 回答 1

2

正如@joran 所提到的,只有在不幸bty地在命令中使用“plot”类型时才会尊重该参数。box()但是,您可以自己画线

par(fig = c(.1,.9,.1,.9), plt = c(.1,.5,.1,.9))
plot(c(1,2,3),c(1,2,3))
par(fig = c(.1,.9,.1,.9), plt = c(.5,.9,.1,.9), new=T)
plot(c(1,2,3),c(1,2,3))
par(fig = c(0,1,0,1), plt = c(0,1,0,1))
lines(grconvertX(c(0,0,1,1), "nfc","user"), 
    grconvertY(c(1,0,0,1), "nfc","user"), 
    col="blue", lwd=4)

在此处输入图像描述

于 2014-06-11T15:45:10.177 回答