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

"Dr. Jens Oehlschlägel" jens.oehlschlaegel@bbdo-interone.de" <jens.oehlschlaegel@bbdo-interone.de
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.

> This is a feature!
> 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?

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.

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.

Best regards


Jens Oehlschlägel

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._