On Jan 23, 2011, at 10:44 AM, Tony Plate wrote:

> Request: An additional hook in plot.new() that is called prior to the call to 
> .Internal(plot.new()).
> Reason: To allow the hook to set up or modify a graphics device that the new 
> plot will appear in.
> 
> The code change needed for this is simple - just 4 new lines of R code in 
> src/library/graphics/R/plot.R:plot.new()
> 
> Current definition of plot.new() in src/library/graphics/R/plot.R:
> 
> plot.new <- function()
> {
>    .Internal(plot.new())
>    for(fun in getHook("plot.new")) {
>        if(is.character(fun)) fun <- get(fun)
>        try(fun())
>    }
>    invisible()
> }
> 
> New definition of plot.new() in src/library/graphics/R/plot.R:
> 
> plot.new <- function()
> {
>    for(fun in getHook("plot.prenew")) {
>        if(is.character(fun)) fun <- get(fun)
>        try(fun())
>    }
>    .Internal(plot.new())
>    for(fun in getHook("plot.new")) {
>        if(is.character(fun)) fun <- get(fun)
>        try(fun())
>    }
>    invisible()
> }
> 
> In src/library/graphics/man/frame.Rd after the existing sentence beginning 
> "There is a hook..." in the DETAILS section, the following sentence could be 
> added:
> 
> "There is another hook called \code{"plot.prenew"} which is called before 
> advancing the frame.  This hook can be used to create a new plot "
> 
> The name of the hook is not very important -- I've suggested "plot.prenew" 
> here.  Another possibility could be "plot.new0".
> 
> More detail on the reason:
> 
> In a tabbed graphics widget 
> (https://r-forge.r-project.org/projects/tabbedplots/ ), having this hook 
> would enable it to operate in a mode where a new tab is automatically created 
> for each new plot.
> 

Just note on the latter: I would expect this to be usually better handled by 
the device/UI as you will be in conflict with things like plot history, already 
supported tabbed devices etc. Do you have a use case where the above has any 
benefits over separate devices in tabs? (The website has little detail so I'm 
just guessing what you're up to ..).

Cheers,
Simon

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to