[Rd] Re: AW: par(par()) corrupts devices (PR#807)

Prof Brian Ripley Prof Brian Ripley <ripley@stats.ox.ac.uk>
Mon, 15 Jan 2001 12:57:30 +0000 (GMT)


> From: "Dr. Jens Oehlschlägel" <jens.oehlschlaegel@bbdo-interone.de>
> Date: Mon, 15 Jan 2001 13:58:00 +0100
> 
> Dear Prof. Ripley,
> 
> I do not insist that features are bugs, so I stop sending this to r-bugs 
> and cc r-devel instead
> 
> > I am replying to this from the archive: I did not actually receive a 
> copy.
> 
> But it is right to sent bug reports ONLY to r-bugs, isn't it?
> I'am actually using a old version of outlook, and some mails from r-help 
> appear as attachments, may it's an outlook problem.

My guess is that it was an R-bugs mail distribution problem at KU.
Certainly not your end.

> > This is a feature!

(I was being somewhat ironic. It was a design error.)

> > You set par(pin=), and that takes precedence over
> > par(pty=).  Same with par(plt=).
> >
> > To unjam it, you need e.g.  par(mai=old.par$mai)
> >
> > I think that par(pty=) should revert to a default plot spec, and will
> > change this.  But, the problem with restoring lists like that is that
> > it depends on exactly the order of the params as they interact.
> > It is *not* a good idea.  And no.readonly=T does not help as
> > plt and pin are not readonly.  If the user has resized the device before
> > restoration, it's pretty chancy what it gets set to.
> 
> Thank you for explaining the way it happens. I must admit, that again I am 
> baffled things do not work as I expect. WHAT IS THE RECOMMENDED WAY TO 
> RESTORE GRAPHICAL PARAMETERS TO EXACTLY WHAT THEY WERE?

Should work in 1.2.1 if the size is unchanged.

> I admit, I expected par(par()) not to change anything (I remember vague 
> that it worked with the prototype), but in this case it is not (only) a 
> problem of restoring a list. Just setting par(pin) and "re-setting" it DOES 
> CHANGE the device: subsequent par(pty="s") are ignored.

No longer in 1.2.1.

> I am shure I am not the only one who expected the on.exit() stuff within 
> the following function to leave the graphical parameters UNCHANGED, but it 
> doesn't.
> 
> somefunc <- function(){
> 	oldpin <- par(pin=par("pin"))
> 	on.exit(par(oldpin))
> 	plot(1,1)
> }
> 
> windows(5,3)
> 
> par(pty="s")
> plot(1,1)
> # square
> par(pty="m")
> plot(1,1)
> 
> # which settings do we have before
> par1 <- par()
> 
> somefunc()
> 
> # which settings do we have now
> par2 <- par()
> # do they differ: yes on plt
> all.equal(par1, par2)
> 
> # reset plt
> par(plt=par1$plt)
> 
> # which settings do we have now
> par2 <- par()
> # do they differ: no
> all.equal(par1, par2)
> 
> par(pty="s")
> plot(1,1)
> #still not square
> #i.e we have hidden parameters
> #because all par() are restored to values where par(pty="s") did work
> 
> > if the user has resized the device before restoration, it's pretty chancy 
> what it gets set to.
> 
> I find it frightening to discover that we obvisously have hidden device 
> parameters, and more frigthening that they may be modified by resizing.
> Sorry that I can't provide code fix, but this is far to deep within the 
> heart of R.

That's not quite right.  R has several pars doing the same thing.  They
will give different answers after re-sizing, and the last one used wins
out.  S does not have this problem because (essentially) it does not
resize.  Ideally there would be a way to save just one of the 
conflicting options.


-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._