Dear colleagues, For the past two weeks we have been struggling to create a proper image with stable pixels, height & width from R for various screen resolutions. We are trying to generate a wmf image with fixed pixels, fixed height & fixed width. But the problem we are facing is that when the same code is run on a different screen resolution the dimensions of the image are no longer the same. We would like to generate an image with height=16.6 cm and width=25 cm. Example code: ##Width & height in inches height <- 6.53 width <- 9.84 h <- height + (height*0.128) #Correcting the height so that when inserted into word doc height in the Original size is 16.6cm w <- width + (width*0.0570) #Correcting the width so that when inserted into word doc width in the Original size is 25cm win.metafile("path to save\\test.wmf", height=h, width=w, restoreConsole TRUE) boxplot(1:100) dev.off() When this image is generated on a screen resolution *1280x1024* ==> height =16.6cm ; width=25cm ; pixels=999x708 *1920x1080 *==> height =15.73cm ; width=16.6cm ; pixels=999x708 Is it possible to keep all the 3 things fixed across different screen resolutions? Please find attached the images generated in the 2 resolutions. It would be of great help if anyone could suggest what could be done. Thanks in advance!!! Regards, Karthik
On 07/12/2013 12:46, Venkat Karthik wrote:> Dear colleagues, > > For the past two weeks we have been struggling to create a proper image > with stable pixels, height & width from R for various screen resolutions.You cannot do that: it is a function of the format and how Microsoft's GDI works.> We are trying to generate a wmf image with fixed pixels, fixed height & > fixed width. But the problem we are facing is that when the same code isWhy? .wmf is only useful if it is a vector file, and 'pixels' then do not matter.> run on a different screen resolution the dimensions of the image are no > longer the same. > > We would like to generate an image with height=16.6 cm and width=25 cm. > Example code: > ##Width & height in inches > height <- 6.53 > width <- 9.84 > h <- height + (height*0.128) #Correcting the height so that when inserted > into word doc height in the Original size is 16.6cm > w <- width + (width*0.0570) #Correcting the width so that when inserted > into word doc width in the Original size is 25cm > win.metafile("path to save\\test.wmf", height=h, width=w, restoreConsole > TRUE) > boxplot(1:100) > dev.off() > > When this image is generated on a screen resolution > *1280x1024* ==> height =16.6cm ; width=25cm ; pixels=999x708 > *1920x1080 *==> height =15.73cm ; width=16.6cm ; pixels=999x708 > > Is it possible to keep all the 3 things fixed across different screen > resolutions? > > Please find attached the images generated in the 2 resolutions. > > It would be of great help if anyone could suggest what could be done. > > Thanks in advance!!! > > Regards, > Karthik > > > > ______________________________________________ > R-help at r-project.org 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. >-- Brian D. Ripley, ripley at 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
________________________________________> From:Venkat Karthik [tvkarthik05 at gmail.com] > We are trying to generate a wmf image with fixed pixels, fixed height & > fixed width. But the problem we are facing is that when the same code is > run on a different screen resolution the dimensions of the image are no > longer the same.In what medium are you measuring the size of the image? If you're reading on screen, try reading the help page for ?windows, where it says "The size of a window is computed from information provided about the display: it depends on the system being configured accurately. By default a screen device asks Windows for the number of pixels per inch. This can be overridden (it is often wrong) by specifying ?xpinch? and ?ypinch?" ... and rather more. Broadly, though, you are generating a vector image of defined size in some medium. There is no meaningful pixel count until you use a raster device to display it, and when you do, the size depends entirely on what the device thinks its pixel size is. And it seems that windows is not often right about it. S ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}}