Re: [R] termplot and ylim

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sun 16 Jul 2006 - 00:30:28 EST

It looks like a bug or at least an omission.

Try the following. It creates a new termplot function which in turn defines a plot function which looks for a ylims= arg and, if present, replaces the ylim= arg with ylims= and then calls the real plot from the graphics package with the new set of arguments.

It then defines a new proto object, i.e. an environment, whose parent is the environment within the new termplot we are setting up. It places a copy of termplot from the stats package in that proto object naming the copy f. This has the side effect of resetting f''s parent to the proto object so that when f calls plot it finds the plot we just defined instead of the usual plot.

Note that one uses ylims= instead of ylim in the call.

termplot <- function(...) {

	plot <- function(...) { # replace ylim= with ylims=
		args <- list(...)
		if ("ylims" %in% names(args)) {
			args$ylim <- args$ylims
			args$ylims <- NULL
		}
		do.call(graphics::plot, args)
	}
	proto(f = stats::termplot)[["f"]](...)

}

# test
library(proto)
L <- lm(y ~ x, data.frame(x = 1:10, y = 10:1)) termplot(L, ylims = 1:2)

On 7/15/06, Andreas Beyerlein <AndiBuck@gmx.de> wrote:
> Hi together,
>
> I always get an error message with using ylim in termplot(), like this:
>
> > x<-(1:10)
> > y<-(10:1)
> > l<-lm(y~x)
> > termplot(l,ylim=c(1,2))
>
> Is this a bug, or is there another possibility to do that? Especially, I would like to use term.plot() for gamlss objects.
>
> Thanks for your help!
> Andreas
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
>
>
> Echte DSL-Flatrate dauerhaft für 0,- Euro*!
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Jul 16 00:39:39 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 16 Jul 2006 - 02:13:31 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.