[R] Using metric units in plots

Gavin Simpson gavin.simpson at ucl.ac.uk
Fri Jun 20 14:08:52 CEST 2008


On Fri, 2008-06-20 at 09:09 -0200, Alberto Monteiro wrote:
> Philip Rhoades wrote:
> > 
> > This is a bit confusing - as far as I can see, ALL the pars use 
> > inches? I understand the US effect but shouldn't Metric units be 
> > supported directly?
> > 
> That's one of my complains, but it seems that this will take time.
> I don't believe it would be too hard to implement metric parameters
> in every function.

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)))
plot(1:10)
par(op)

HTH

G

> 
> Maybe Humanity must lose a few more people in airplane crashes
> or nuclear plant meltdowns before we ban those unscientific units
> from use.
> 
> Alberto Monteiro
> 
> ______________________________________________
> 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list