# Re: [R] Using metric units in plots

From: Patrick Connolly <p_connolly_at_slingshot.co.nz>
Date: Thu, 26 Jun 2008 08:28:28 +1200

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

~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help