我想在一页上放置两个正方形图,并让结果图填满一张纸的大部分。这似乎是一个非常基本的想法。但是,默认似乎是创建矩形图。当我指定绘图为正方形时,其大小相对于页面会变得很小。如果我成功放大了正方形图,则轴标签将被隐藏。我尝试了许多omimarlayout的变体,但均未成功。

我想使用基本R。感谢您的任何建议。

setwd('c:/users/markm/simple R programs')

x <- 1:10
y1.1 <- x ^2
y1.2 <- x + 50
y1.3 <- x ^1.5

pdf("plots_June1_2015.pdf")

par(mfrow=c(2,1))

     plot(x, y1.1, type = 'l', col = 'black' , lwd = 1, lty = 1,
          xlab = 'My X Axis',
          ylab = 'My Y Axis')
          lines(x, y1.2, type = 'l', col = 'black' , lwd = 1, lty = 2)
          lines(x, y1.3, type = 'l', col = 'black' , lwd = 1, lty = 3)
     title('Plot One')

     plot(x, y1.1, type = 'l', col = 'black' , lwd = 1, lty = 1,
          xlab = 'My X Axis',
          ylab = 'My Y Axis')
          lines(x, y1.2, type = 'l', col = 'black', lwd = 1, lty = 2)
          lines(x, y1.3, type = 'l', col = 'black', lwd = 1, lty = 3)
     title('Plot Two')

dev.off()

以下是各种失败的尝试:
#par(mfrow=c(2,1), omi=c(0.1,0.1,0.1,0.1), mar=c(3,3,3,3), cex.lab=0.75, pty="s", cex.axis=0.75)
#par(mfrow=c(2,1), omi=c(0.1,0.1,0.1,0.1), mar=c(3,3,3,3), cex.lab=0.75, cex.axis=0.75)
#par(mfrow=c(2,1), omi=c(1,1,1,1), mar=c(3,3,3,3), cex.lab=0.75, cex.axis=0.75)
#par(mfrow=c(2,1), omi=c(1,1,1,1), cex.lab=0.75, cex.axis=0.75)
#par(mfrow=c(2,1), omi=c(1,1,1,1), cex.lab=0.75, cex.axis=0.75, pty="s")
#par(mfrow=c(2,1), omi=c(1,1,1,1), cex.lab=0.75, cex.axis=0.75, asp=1)
#par(mfrow=c(2,1))
#layout(matrix(c(1,1), 2, 1, byrow = TRUE), widths=c(3,1), heights=c(1,2))
#layout(matrix(c(2,2), 2, 1, byrow = TRUE), widths=c(3,1), heights=c(1,2))
#layout(matrix(c(2,2), 2, 1, byrow = TRUE), widths=c(1,1), heights=c(1,1))
#layout(matrix(c(2,2), 2, 1, byrow = TRUE), widths=c(1,1), heights=c(1,1))
#layout(matrix(c(2,2), 2, 1, byrow = TRUE), widths=lcm(7,7), heights=c(1,1))

最佳答案

我认为您正在关注错误的问题。最终大小由pdf调用而不是par定义。使用

pdf("plots_June1_2015.pdf", width = 11.69, height = 16.53)

(11.69 x 16.53是A3纸张尺寸,以英寸according to Google为单位)

还有我发布的未更改的代码(这是pdf的打印屏幕)

关于r - 填满一张纸的两个正方形图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30584512/

10-12 19:22