[R] setting 'layout' locally within functions

Paul Murrell p.murrell at auckland.ac.nz
Wed Jun 22 22:20:49 CEST 2011


Hi

On 23/06/2011 2:58 a.m., Simon Goodman wrote:
> Using layout I've created a function that makes a 2 panel plot - comprising a
> main plot, and a sub-panel with custom legend.
>
> I would now like to use layout to create multiple panels with plots created
> by my function, however the values for layout set in the function act
> globally, stopping me from setting this up how I want.
>
> So if I say:
>
> layout(matrix(1:2, 1,2))
> my.plot(data)
>
> I end up with a single plot according the layout format specified by the
> function, rather than a plot generated by the function in the left hand
> panel of the matrix that should be specified by the first layout command.
>
> Is there a way to use layout in a subsetable, hierarchical way?

You have just described the 'grid' graphics package.

Paul

> Thanks, Simon
>
> --
> View this message in context: http://r.789695.n4.nabble.com/setting-layout-locally-within-functions-tp3617257p3617257.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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 Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



More information about the R-help mailing list