【问题标题】:R: setting multiple plot heights with parR:使用标准设置多个绘图高度
【发布时间】:2015-05-10 20:43:03
【问题描述】:

我正在尝试将三个图表绘制在一起,一个在另一个之下。 我想使用 par 将第一个图表的高度设置为其他图表的两倍,但我在使用高度参数时遇到了困难。

par(mfrow = c(3, 1),mar=c(2, 4, 2, 0.2), heights=c(2,1,1))

plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")
plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")
plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")

感谢您的帮助。

【问题讨论】:

    标签: r plot


    【解决方案1】:

    您可以为此使用layout

    #the first argument is a matrix that shows the order of the graphs
    #in this case the matrix has 1 column and 3 rows. therefore, graphs 1,2,3
    #will be ploted in this order, one below the other
    #you then need to adjust the heights and the widths for each plot
    nf <- layout(matrix(c(1,2,3),ncol=1), widths=c(4,4,4), heights=c(2,1,1), TRUE) 
    #typing the below command will let you see how the plots will be filled in.
    #layout.show(nf)
    
    #then you just run your plots
    plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")
    plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")
    plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-13
      • 1970-01-01
      • 1970-01-01
      • 2011-06-07
      • 2015-04-08
      相关资源
      最近更新 更多