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
wmf screen resolution problem!!!
7 messages · Venkat Karthik, Brian Ripley, S Ellison +3 more
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 is
Why? .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}}
Dear R Users I have the vector X <- c( 6 , 4 ,12 , 3) I would like to build a new vector by to transform it into Y <- c(rep(X[1], X[1]), rep(X[2], X[2]), rep(X[3], X[3]), rep(X[4], X[4])) Have you a more elegant answer ? PS : Sorry for this basic question
Michel ARNAUD Charg? de mission aupr?s du DRH DGDRD-Drh - TA 174/04 Av Agropolis 34398 Montpellier cedex 5 tel : 04.67.61.75.38 fax : 04.67.61.57.87 port: 06.47.43.55.31
On 09-12-2013, at 08:04, Arnaud Michel <michel.arnaud at cirad.fr> wrote:
Dear R Users I have the vector X <- c( 6 , 4 ,12 , 3) I would like to build a new vector by to transform it into Y <- c(rep(X[1], X[1]), rep(X[2], X[2]), rep(X[3], X[3]), rep(X[4], X[4])) Have you a more elegant answer ?
Have a good read of ?rep. Try this: rep(X,times=X) Berend
Hello, Are you looking for Y <- rep(X, X) ? Regards, Pascal
On 9 December 2013 16:04, Arnaud Michel <michel.arnaud at cirad.fr> wrote:
Dear R Users I have the vector X <- c( 6 , 4 ,12 , 3) I would like to build a new vector by to transform it into Y <- c(rep(X[1], X[1]), rep(X[2], X[2]), rep(X[3], X[3]), rep(X[4], X[4])) Have you a more elegant answer ? PS : Sorry for this basic question -- Michel ARNAUD Charg? de mission aupr?s du DRH DGDRD-Drh - TA 174/04 Av Agropolis 34398 Montpellier cedex 5 tel : 04.67.61.75.38 fax : 04.67.61.57.87 port: 06.47.43.55.31
______________________________________________ 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.
Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan
Thank you Michel Le 09/12/2013 08:14, Berend Hasselman a ?crit :
On 09-12-2013, at 08:04, Arnaud Michel <michel.arnaud at cirad.fr> wrote:
Dear R Users I have the vector X <- c( 6 , 4 ,12 , 3) I would like to build a new vector by to transform it into Y <- c(rep(X[1], X[1]), rep(X[2], X[2]), rep(X[3], X[3]), rep(X[4], X[4])) Have you a more elegant answer ?
Have a good read of ?rep. Try this: rep(X,times=X) Berend
Michel ARNAUD Charg? de mission aupr?s du DRH DGDRD-Drh - TA 174/04 Av Agropolis 34398 Montpellier cedex 5 tel : 04.67.61.75.38 fax : 04.67.61.57.87 port: 06.47.43.55.31