[R] Using metric units in plots

Patrick Connolly p_connolly at slingshot.co.nz
Wed Jun 25 22:28:28 CEST 2008


On Fri, 20-Jun-2008 at 01:08PM +0100, Gavin Simpson wrote:


|> But it is not too difficult to do this yourself:
|> 
|> in2cm <- function(x) return(x * 2.54)
|> 
|> cm2in <- function(x) return(x * 0.3937008)
|> 
|> then use in2cm() or cm2in() depending on what you want to achieve. If
|> you want a margin of 4cm all round the plot:
|> 
|> op <- par(mai = cm2in(rep(4, 4)))

For those watching their keystroke footprints, it's slightly less to
do this:

   op <- par(mai = rep(4, 4)/2.54)

I personally find mm the most convenient unit so I typically set pdf
device widths and heights like this:

height = 265/25.4, width = 180/25.4

It would be nice to have an omm and mam as alternatives to omi and mai
respectively, but we have oodles of par settings already.  Then
there's a lot of people who would prefer to use cm instead of mm, so
there'd have to be settings for those as well.  Too much already.

I've resigned myself to typing a '/25.4' sequence after the number of
mm I'm thinking of, and that's not hard to do.



-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}          		 Great minds discuss ideas    
 _( Y )_  	  	        Middle minds discuss events 
(:_~*~_:) 	       		 Small minds discuss people  
 (_)-(_)  	                           ..... Anon
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.



More information about the R-help mailing list