multiple plots in single frame: 2 upper, 1 lower

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

multiple plots in single frame: 2 upper, 1 lower

DrCJones
Hi,

par(mfrow = c(2,2))

will create a 2x2 window that I can use to plot 4 diferent figures in:
[plot1 plot2]
[plot3 plot4]

But how can do 3 so that the bottom spans the width of the upper two:

[plot1 plot1]
[p   l  o  t 3]

Is this possible in R?
Reply | Threaded
Open this post in threaded view
|

Re: multiple plots in single frame: 2 upper, 1 lower

Joshua Wiley-2
Hi,

Try looking at ?layout.  Here is a simple example:

layout(matrix(c(1, 2, 3, 3), 2, byrow = TRUE))
plot(1:10); plot(11:20); plot(21:40)

Cheers,

Josh

On Tue, Jul 19, 2011 at 4:07 PM, DrCJones <[hidden email]> wrote:

> Hi,
>
> par(mfrow = c(2,2))
>
> will create a 2x2 window that I can use to plot 4 diferent figures in:
> [plot1 plot2]
> [plot3 plot4]
>
> But how can do 3 so that the bottom spans the width of the upper two:
>
> [plot1 plot1]
> [p   l  o  t 3]
>
> Is this possible in R?
>
> --
> View this message in context: http://r.789695.n4.nabble.com/multiple-plots-in-single-frame-2-upper-1-lower-tp3679574p3679574.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
https://joshuawiley.com/

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: multiple plots in single frame: 2 upper, 1 lower

Dieter Menne
In reply to this post by DrCJones
DrCJones wrote
But how can do 3 so that the bottom spans the width of the upper two:

[plot1 plot1]
[p   l  o  t 3]
?layout

for standard graphics (plot..), but that's what you are referring to. For trellis, you must use other methods.

Dieter

Reply | Threaded
Open this post in threaded view
|

Re: multiple plots in single frame: 2 upper, 1 lower

Rolf Turner-3
In reply to this post by DrCJones
On 20/07/11 11:07, DrCJones wrote:

> Hi,
>
> par(mfrow = c(2,2))
>
> will create a 2x2 window that I can use to plot 4 diferent figures in:
> [plot1 plot2]
> [plot3 plot4]
>
> But how can do 3 so that the bottom spans the width of the upper two:
>
> [plot1 plot1]
> [p   l  o  t 3]
>
> Is this possible in R?

In R ***anything*** is possible. :-)

Your requirement is no only possible, but easy!

See ?layout

You may have to expend a bit of effort to understand the syntax, but
that will be good for your karma. :-)  It ***will*** do exactly what you
want, if you ask it nicely.

     cheers,

         Rolf Turner

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: multiple plots in single frame: 2 upper, 1 lower

DrCJones
Layout did it! Thanks guys :)
Reply | Threaded
Open this post in threaded view
|

Re: multiple plots in single frame: 2 upper, 1 lower

Gavin Simpson
In reply to this post by Rolf Turner-3
On Wed, 2011-07-20 at 23:38 +1200, Rolf Turner wrote:

> On 20/07/11 11:07, DrCJones wrote:
> > Hi,
> >
> > par(mfrow = c(2,2))
> >
> > will create a 2x2 window that I can use to plot 4 diferent figures in:
> > [plot1 plot2]
> > [plot3 plot4]
> >
> > But how can do 3 so that the bottom spans the width of the upper two:
> >
> > [plot1 plot1]
> > [p   l  o  t 3]
> >
> > Is this possible in R?
>
> In R ***anything*** is possible. :-)
>
> Your requirement is no only possible, but easy!
>
> See ?layout
>
> You may have to expend a bit of effort to understand the syntax, but
> that will be good for your karma. :-)

It may help the OP to think of the layout as a 2*2 matrix:

1 2
3 4

say, with plot 3 using regions 3 and 4. If we fill the same matrix with
the plot number we want to draw in it, we have

1 2
3 3

>From there it is easy to specify the layout by directly building that
matrix in R:

> (m <- matrix(c(1:3,3), ncol = 2, byrow = TRUE))
     [,1] [,2]
[1,]    1    2
[2,]    3    3

and pass that to `layout()`

layout(m)
## invisible() just to stop replicate returning something visible
invisible(replicate(3, plot(1:10)))
layout(1)

HTH

G

>  It ***will*** do exactly what you
> want, if you ask it nicely.
>
>      cheers,
>
>          Rolf Turner
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.