0

我试图生成一个图,但我需要跨越多个页面上的图像。

 pdf(file = ("Rplot%03d.pdf"), onefile=FALSE)
 height<-100
 plot(-1,-1,xlim=c(0,50),ylim=c(0,height),axes=F,ann = FALSE)

 for (i in 1:100)
 {
    rect(0, height, 10, height+.15, col="red", border = "black")
    rect(11, height, 40, height+.15, col="green", border = "black")
    rect(41, height, 50, height+.15, col="blue", border = "black")
    height<-height-1
 }

 axis(3,at=c(,0,10,20,30,40,50),cex.axis=.3,las=2)
 dev.off()

我想在多个 pdf 上跨越这些矩形图 (RGB),例如每页 10 个条,从每页上的比例开始。我该如何实施?

第 1 页:

  Scale
  rectangular bar (with three different color)
  rectangular bar (with three different color)
  .......   (7 times)
  .......
  rectangular bar (with three different color) 

第2页:

  Scale
  rectangular bar (with three different color)
  rectangular bar (with three different color)
  .......   (7 times)
  .......
  rectangular bar (with three different color) 

第 3 页:

  Scale
  rectangular bar (with three different color)
  rectangular bar (with three different color)
  .......   (7 times)
  .......
  rectangular bar (with three different color) 
4

1 回答 1

2

你不能;PDF 中的每个“页面”都是一个单独且完整的图。实现您想要的唯一方法是plot()使用相同的方法对每个调用进行多次调用,ylim并且只使用足够的 x 数据来绘制 10 个条形图。要实现这一点,您需要将数据集分成 10 个条形块,并将每个图作为外部for ()循环的一部分开始。

于 2013-08-02T03:21:06.393 回答