Change the size of a plot when plotting multiple plots in R

前端 未结 2 704
自闭症患者
自闭症患者 2021-02-01 07:46

I want to know if there is a way to define the size of a plot in R, when you are plotting different plots using the par(mfrow=c()) function.

As a simple example take thi

相关标签:
2条回答
  • 2021-02-01 08:07

    Try layout for example

    layout(matrix(c(1,1,2,3,4,4), nrow = 3, ncol = 2, byrow = TRUE))
    plot(1,main=1)
    plot(2,main=2)
    plot(3,main=3)
    plot(4,main=4)
    

    enter image description here

    layout(matrix(c(1,1,2,1,1,2,3,4,4), nrow = 3, ncol = 3, byrow = TRUE))
    plot(1,main=1)
    plot(2,main=2)
    plot(3,main=3)
    plot(4,main=4)
    

    give you enter image description here

    Also you can use par(fig= ) for example

    par(mar=c(2,2,2,1))
    par(fig=c(0,7,6,10)/10)
    plot(1,main=1)
    par(fig=c(7,10,6,10)/10)
    par(new=T)
    plot(2,main=2)
    par(fig=c(0,7,0,6)/10)
    par(new=T)
    plot(3,main=3)
    par(fig=c(7,10,0,6)/10)
    par(new=T)
    plot(4,main=4)
    

    Give you enter image description here

    but i think layout better for use

    0 讨论(0)
  • 2021-02-01 08:22

    another option would be to use ggarrange. the nice thing about it is that you can use ggarange not just on plots but also on "arranged" plots that you've created with ggarrange, which makes it easy to first arrange e.g. two smaller plots and then arrange them together with one bigger one.

    0 讨论(0)
提交回复
热议问题