Re: [R] screen resolution effects on graphics

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue 29 Aug 2006 - 21:30:53 EST

In thinking about this some more Romain's idea of using the browser to get this information can be done like this. This solution only works with Internet Explorer:

library(RDCOMClient)
ie <- COMCreate("InternetExplorer.Application") ie$Navigate("about:blank")
width <- ie[["document"]][["ParentWindow"]][["screen"]][["width"]] height <- ie[["document"]][["ParentWindow"]][["screen"]][["height"]] ie$Quit()

On 8/28/06, Gabor Grothendieck <ggrothendieck@gmail.com> wrote:
> I think there are problems with browseURL on Windows XP with IE.
> Put the file in screen.htm and then run:
>
> shell.exec("screen.htm")
>
> it will come up -- it will block it and you will have to click to
> unblock it; however,
> that will interfere with any automatic procedure.
>
> On 8/28/06, Charles Annis, P.E.
> <Charles.Annis@statisticalengineering.com> wrote:
> > Romain:
> >
> > > a <- tempfile()
> > > cat('<html><script type="text/javascript"> document.write(screen.width) ;
> > </script></html>', file=a)
> > > browseURL(a)
> > >
> >
> > The object "a" was created, but no browser opened.
> >
> > > ls()
> > [1] "a"
> > > a
> > [1] "C:\\DOCUME~1\\CHARLE~1\\LOCALS~1\\Temp\\RtmpRgWrqb\\file678418be"
> > >
> >
> >
> >
> > Charles Annis, P.E.
> >
> > Charles.Annis@StatisticalEngineering.com
> > phone: 561-352-9699
> > eFax: 614-455-3265
> > http://www.StatisticalEngineering.com
> >
> >
> > -----Original Message-----
> > From: r-help-bounces@stat.math.ethz.ch
> > [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Romain Francois
> > Sent: Monday, August 28, 2006 2:30 PM
> > To: Prof Brian Ripley
> > Cc: Charles Annis, P.E.; r-help@stat.math.ethz.ch
> > Subject: Re: [R] screen resolution effects on graphics
> >
> > Prof Brian Ripley a écrit :
> > > On Mon, 28 Aug 2006, Charles Annis, P.E. wrote:
> > >
> > >
> > >> Greetings, R-Citizens:
> > >>
> > >> I have the good fortune of working with a 19" 1280 X 1024 pixel monitor.
> > My
> > >>
> > >
> > > (Similar to our student lab has used for many years.)
> > >
> > >
> > >> R-code produces nice-looking graphics on this machine but the same code
> > >> results in crowded plots on an older machine with 800 X 600 resolution.
> > In
> > >> hindsight this seems obvious, but I didn't anticipate it.
> > >>
> > >
> > > It is not obvious to me: I have never experienced it. What OS and
> > > graphics device is this?
> > >
> > > Almost all of R's graphics is independent of the screen resolution (the
> > > exception being the bitmapped devices such as jpeg), with things sized in
> > > inches or points. My machines are 1600x1200 (apart from 1280x800 on my
> > > laptop), so I meet a considerable reduction when using a computer
> > > projector, and my plots do not look crowded.
> > >
> > > However, one issue is when the OS has a seriously incorrect setting for
> > > the screen resolution and so does not give the sizes asked for by R. We
> > > have seen that on both Linux and Windows, and the windows() device has
> > > arguments to set the correct values. (On X11 you should be able to set
> > > this in Xconfig files.)
> > >
> > > If this is Windows, check carefully the description of the initial screen
> > > size in ?windows. That can have unexpected effects on physically small
> > > screens.
> > >
> > > At one time the X11() device was set up to assume 75dpi unless the
> > > reported resolution was 100+/-0.5dpi. My then monitor reported 99.2 dpi
> > > and so things came out at 3/4 of the intended size. We fixed that quite a
> >
> > > while back.
> > >
> > >
> > >> My code will be used on machines with varying graphics (and memory)
> > >> capacity. Is there a way I can check the native resolution of the
> > machine
> > >> so that I can make adjustments to my code for the possible limitations of
> > >> the machine running it?
> > >>
> > >
> > > Only via C code, which is how R does it.
> > Hi,
> >
> > Javascript knows, can we ask him ?
> >
> > I mean, if I do that in R :
> >
> > a <- tempfile()
> > cat('<html><script type="text/javascript"> document.write(screen.width)
> > ; </script></html>', file=a)
> > browseURL(a)
> >
> > I get "1920" in my browser's window. Can R read it ?
> >
> > Romain
> >
> > ______________________________________________
> > 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
> > and provide commented, minimal, self-contained, reproducible code.
> >
> > ______________________________________________
> > 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
> > and provide commented, minimal, self-contained, reproducible code.
> >
>



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 and provide commented, minimal, self-contained, reproducible code. Received on Wed Aug 30 06:57:46 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 Wed 30 Aug 2006 - 08:23:35 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.