# [R] calling plot

Bert Gunter bgunter.4567 at gmail.com
Tue Feb 9 16:51:53 CET 2016

```Spencer, et. al.:

As I suspected, my previous "solution" was pretty stupid. Here is, I
think, the "right" way to

plotxy <- function(x,...){
mcall <- match.call(expand.dots=FALSE)
mcall[[1]]<- plot.default
eval(mcall)
}

Best,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Feb 8, 2016 at 8:10 PM, Spencer Graves
<spencer.graves at effectivedefense.org> wrote:
> Hi, Jeff et al.:
>
>
> On 2/8/2016 9:52 PM, Jeff Newmiller wrote:
>> plotxy(y1~x1, XY, xlim=c(0, max(XY\$x1)))
>
>
>        Yes, Thanks.
>
>
>        Is there a way to do this from within "plotxy", so I can call
> "plotxy" as I call "plot"?
>
>
>        Thanks,
>        Spencer
>
>
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>> On February 8, 2016 7:17:57 PM PST, Spencer Graves
>> <spencer.graves at effectivedefense.org> wrote:
>>
>>     I'm getting an interesting error:
>>
>>
>>         plotxy <- function(x, ...){
>>
>>     +   plot(x, ...)
>>     + }
>>
>>         XY <- data.frame(x1=1:3, y1=4:6) plotxy(y1~x1, XY, xlim=c(0,
>>         max(x1)))
>>
>>        Show Traceback
>>
>>        Rerun with Debug
>>
>>
>>             The following work:
>>
>>
>>     plotxy(y1~x1, XY)
>>     plot(y1~x1, XY, xlim=c(0, max(x1)))
>>
>>
>>             Within "plotxy", R can't find "x1" to compute "xlim".  Is there a
>>     way I can make x1 available to xlim?
>>
>>
>>             Thanks,
>>             Spencer
>>
>>     ------------------------------------------------------------------------
>>
>>     R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>     https://stat.ethz.ch/mailman/listinfo/r-help
>>     and provide commented, minimal, self-contained, reproducible code.
>>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> and provide commented, minimal, self-contained, reproducible code.

```