[Rd] Re: some problems with windows(rescale=) (PR#794)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Thu, 11 Jan 2001 00:11:42 +0100 (MET)


Part 1) is basically that the initial rescaling is done if the window is
too large to fit on the screen.  That's true and obvious (no scrollbars)
and intentional and on the help page.  As ever, you need to report bugs on
what is documented, not what you would like.

This will be changed for 1.2.1, but was several hours' work.  I have also
cleaned up the scrollbar behaviour.

Part 2) I just can't reproduce.  When I follow the instructions, all the
settings revert to very close to the originals and the plot looks the same.

In summary, there is no reproducible evidence of a bug here, and never was.
A feature request will appear in 1.2.1.

BDR

On Fri, 29 Dec 2000 joehl@web.de wrote:

> Dear Prof. Brian Ripley,
>
> Thank you for your answer. You convinced me on one important point, but some issues remain open (revised bug status at the end of this message)
>
> > If these things bother you, could you please supply fixes?
>
> Given that I don't have much experience in C coding, given that I don't know any internals of the R graphics engine (where I think a solution would be best), given that I don't have ever compiled R for Windows (where obviously the rescale stuff happens), it is currently too expensive for me to attack that.
>
> What I definitely can offer is testing and giving replicable bug reports.
>
> Also, given that I am not a member of r-devel and that some r-devel don't think these are clearly bugs, I shrink from producing code that might never make it into R.
>
> > [snipped]
> > Nothing on the help page suggested that the fine details of the R read-only
> > parameters will be as you expected after re-scaling the plot, and it never
> > occurred to me that anyone would expect so.
> > As they are reported by the R
> > graphics engine (which is used unchanged), I expect they are correct in one
> > of the multiple interpretations.
> > [snipped]
>
> Running the risk to repeat me: I am convinced that R like S+ needs a stable representation layer to which a programmer can refer. This is the layer where we talk about "let's layout a DIN A3 Paper, let's use 2 inches margins" and so on and this layer should be independent of actual window size (presentation layer).
>
> One might whish, that R's grapic parameter do not refer to absolute measures and divide the device area rather with relative measures: "let's have 10% margins". However, R allows to specify some parameter in absolute measures (e.g. par(mai=)) and more important some parameters are not free of absolute measures as par(cex=1) refers to a fixed ont size, not to a fixed fraction of the device size. Because of this the RO-device feature par("fin") to me appears not to be an arbitrary size and should be kept stable.
>
> > Possibly.  I don't think the device size is very interesting after
> > rescaling.  What are you using it for?
>
> Well, of course I try to avoid using it.
>
> Checking this more thoroughly I see that with windows(rescale="fit") I INDEED CAN IGNORE par("din") as long as I avoid making any specifications in inches.
>
> Requesting a 16 inch device and getting initially 9 inches CEX is rescaled appropriately, WITH RESPECT to the intended 16 inch device.
>
> Note that we now introduced a device which looks like 9 inch on screen with too small fonts, if asked it tells the user 'I am a 9 inch device (par("din"))' and it does not tell the user 'well, in fact my original size is 16 inches, don't forget'. But this is OK, the rescaling basically works. Thus I have to revise the interpretation of the phenomenon which I observed in comparing the character sizes of the three rescale modes: What I called "strange character sizes" in windows(rescale="fit") seems to make sense. It's rather windows(rescale="fixed") which gives problematic character sizes.
>
> Example
> Finding out the necessary par(cex=) which allows a certain amount of text to fit in a certain fraction of the device size.
>
> ========================
> windows(rescale="fixed")
> does not do rescaling after device initializiation, it's basic idea is to not change the device size at all.
> However, the automatic initial rescaling destroys this idea: if you require a 16 inch device and you get 9 inches, then you can only find out which cex is optimal for 9 inches but applying the result to a 16 inch device fails.
> In short: character size is not correct with respect to those 16 inches we requested, but is correct with respect to those 9 inches we get instead.
> Thus the current implementation does not make sense with devices bigger than the screen.
> ========================
>
> # I intend to layout DIN A3
> width <- 16.53543
> height <- 11.69291
> jandltext <- "there is hardly anything i know for sure\nneither of the future nor of the past\nnor should i know what to ask\nif the person answering was you\n\n(Ernst Jandl, stanzen)"
> windows(width=width, height=height, rescale="fixed")
>
> # using windows() I find out that with cex=3.2 the following commands give a text that exacly fills the plot area (horizontally)
> par(cex=1)
> par(mai=c(0,0,0,0))
> plot.new()
> par(usr=c(0,2,0,2))
> par(c("din","fin","pin"))
> par("usr")
> text(1,1, jandltext, cex=3.2)
>
> dev.off()
> postscript(file = "c:/temp/t.ps", paper="special", width=width, height=height)
>
> # now applying THE SAME commands gives NOT a text that exacly fills the plot area (horizontally).
> par(cex=1)
> par(mai=c(0,0,0,0))
> plot.new()
> par(usr=c(0,2,0,2))
> par(c("din","fin","pin"))
> par("usr")
> text(1,1, jandltext, cex=3.2)
>
> dev.off()
>
>
>
> ======================
> by constrast
> windows(rescale="fit")
> works
> ======================
>
> # I intend to layout DIN A3
> width <- 16.53543
> height <- 11.69291
> jandltext <- "there is hardly anything i know for sure\nneither of the future nor of the past\nnor should i know what to ask\nif the person answering was you\n\n(Ernst Jandl, stanzen)"
> windows(width=width, height=height, rescale="fit")
>
> # using windows() I find out that with cex=5.8 the following commands give a text that exacly fills the plot area (horizontally)
> par(cex=1)
> par(mai=c(0,0,0,0))
> plot.new()
> par(usr=c(0,2,0,2))
> par(c("din","fin","pin"))
> par("usr")
> text(1,1,jandltext, cex=5.8)
>
> dev.off()
> postscript(file = "c:/temp/t.ps", paper="special", width=width, height=height)
>
> # now applying THE SAME commands WORKS
> par(cex=1)
> par(mai=c(0,0,0,0))
> plot.new()
> par(usr=c(0,2,0,2))
> par(c("din","fin","pin"))
> par("usr")
> text(1,1,jandltext, cex=5.8)
>
> dev.off()
>
> However repeated resizing of the window does increase the shown font sizes, look at that:
>
> width <- 8
> height <- 6
> jandltext <- "there is hardly anything i know for sure\nneither of the future nor of the past\nnor should i know what to ask\nif the person answering was you\n\n(Ernst Jandl, stanzen)"
> cex <- 2.8
>
> info <- function(){
> 	user <- strwidth(jandltext, cex=cex, units="user")
> 	inches <- strwidth(jandltext, cex=cex, units="inches")
> 	pin <- par("pin")
> 	din <- par("din")
> 	data.frame(din=din[1], aspectratio=din[1]/din[2], pintodin=pin[1]/din[1], struser=user, strinchtopin=inches/pin[1], strinch=inches)
> }
>
> windows(width=width, height=height, rescale="fit") # this one serves as reference for initial window size
> windows(width=width, height=height, rescale="fit")
> par(cex=1)
> par(mai=c(0,0,0,0))
> plot.new()
> par(usr=c(0,1,0,1))
> par(c("din","fin","pin"))
> par("usr")
> text(0.5,0.5,jandltext, cex=cex)
>
> # Initial measures
> print(static <- info())
>
> # now some VERTICAL resizing and bring window back to original size
> print(static <- rbind(static, info()))
> # we never touched horizontal window size but horiz din differs, strwidthInInches differs not
>
> # now some VERTICAL resizing and bring window back to original size
> print(static <- rbind(static, info()))
> # now everything differs
>
> > print(static <- rbind(static, info()))
>        din aspectratio pintodin   struser strinchtopin   strinch
> 1 8.166667    1.326565        1 0.9859694    0.9859694  8.052083 # start
> 2 6.291905    1.023768        1 1.2797528    1.2797528  8.052083 # after some vertical resizing
> 3 8.166667    1.390765        1 1.2908163    1.2908163 10.541667 # after some horizontal resizing
>
>
>
> So here is my revised bug status:
>
> 1a) windows(rescale="fixed") does not keep original device size
> 1b) windows(rescale="fixed") gives problematic character sizes (because of 1a)
>
> 2) wrong row distances with windows(rescale="fit")
>    This phenomenon also observed under different circumstances
>    see todays mail to r-help
>
> 3a) windows(rescale="fit") destroys aspect ratio
> 3b) repeated rescaling destroys proper font size as well
>
>
> Kind regards and best wishes for 2001
>
>
>
> Jens Oehlschlägel
>
> _______________________________________________________________________________
> Alles unter einem Dach: Informationen, Fun, E-Mails. Bei WEB.DE: http://web.de
> Die große Welt der Kommunikation: E-Mail, Fax, SMS, WAP: http://freemail.web.de
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

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