Skip to content

wmf screen resolution problem!!!

7 messages · Venkat Karthik, Brian Ripley, S Ellison +3 more

#
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:
You cannot do that: it is a function of the format and how Microsoft's 
GDI works.
Why?  .wmf is only useful if it is a vector file, and 'pixels' then do 
not matter.

  
    
#
________________________________________
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
#
On 09-12-2013, at 08:04, Arnaud Michel <michel.arnaud at cirad.fr> wrote:

            
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:

  
    
#
Thank you
Michel
Le 09/12/2013 08:14, Berend Hasselman a ?crit :