Re: [R] Using metric units in plots

2008-06-25 Thread Patrick Connolly
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@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.


Re: [R] Using metric units in plots

2008-06-20 Thread Peter Dalgaard

> And if you think inches are bad, check out "points".
>   
Not to mention "pints"

Cheers,
-p

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@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.


Re: [R] Using metric units in plots

2008-06-20 Thread Jim Lemon
On Fri, 2008-06-20 at 11:26 +0100, Prof Brian Ripley wrote:
> ...
> In base graphics there are a very few par()s that use inches (and I am 
> pretty sure that comes from the US unit as used in S, not the 'Imperial' 
> one -- see e.g. Wikipedia).  But those are rarely used.
> 
My recollection of the Imperial and US units was that inches were the
same and only volumetric measures differed (despite the fact that the
USA officially adopted decimal measures long ago but didn't get around
to using them). Given the fairly rubbery definition of the inch, that
coincidence was pretty surprising.

And if you think inches are bad, check out "points".

Jim

__
R-help@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.


Re: [R] Using metric units in plots

2008-06-20 Thread Gavin Simpson
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@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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@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.


Re: [R] Using metric units in plots

2008-06-20 Thread Alberto Monteiro
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.

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@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.


Re: [R] Using metric units in plots

2008-06-20 Thread Duncan Murdoch

On 20/06/2008 6:41 AM, Philip Rhoades wrote:

Prof Brian Ripley,


Prof Brian Ripley wrote:

On Fri, 20 Jun 2008, Philip Rhoades wrote:


People,

It appears that one has to use Imperial measurements in plot 
parameters?  I can't find any info on using metric units . .

In package grid you can use several different units.



When I search the R site for "grid" I get:

"Package ‘grid’ was removed from the CRAN repository"


That's because it became a base package.  It's distributed with R, not 
as a separate package on CRAN.



In base graphics there are a very few par()s that use inches (and I am 
pretty sure that comes from the US unit as used in S, not the 'Imperial' 
one -- see e.g. Wikipedia).  But those are rarely used.



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?


I believe only inches are used as physical units, but many of the par() 
values don't use physical units.  There are lines, user coordinates, 
etc.  And plot() makes almost no use of physical units.


Duncan Murdoch




Also most graphics devices are dimensioned in inches with resolutions in 
dpi.


Function cm() might help you.



Thanks,

Phil.


__
R-help@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.


Re: [R] Using metric units in plots

2008-06-20 Thread Philip Rhoades

Prof Brian Ripley,


Prof Brian Ripley wrote:

On Fri, 20 Jun 2008, Philip Rhoades wrote:


People,

It appears that one has to use Imperial measurements in plot 
parameters?  I can't find any info on using metric units . .


In package grid you can use several different units.



When I search the R site for "grid" I get:

"Package ‘grid’ was removed from the CRAN repository"


In base graphics there are a very few par()s that use inches (and I am 
pretty sure that comes from the US unit as used in S, not the 'Imperial' 
one -- see e.g. Wikipedia).  But those are rarely used.



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?



Also most graphics devices are dimensioned in inches with resolutions in 
dpi.


Function cm() might help you.



Thanks,

Phil.
--
Philip Rhoades

Pricom Pty Limited  (ACN 003 252 275  ABN 91 003 252 275)
GPO Box 3411
Sydney NSW  2001
Australia
E-mail:  [EMAIL PROTECTED]

__
R-help@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.


Re: [R] Using metric units in plots

2008-06-20 Thread Prof Brian Ripley

On Fri, 20 Jun 2008, Philip Rhoades wrote:


People,

It appears that one has to use Imperial measurements in plot parameters?  I 
can't find any info on using metric units . .


In package grid you can use several different units.

In base graphics there are a very few par()s that use inches (and I am 
pretty sure that comes from the US unit as used in S, not the 'Imperial' 
one -- see e.g. Wikipedia).  But those are rarely used.


Also most graphics devices are dimensioned in inches with resolutions in 
dpi.


Function cm() might help you.



Thanks,

Phil.
--
Philip Rhoades

Pricom Pty Limited  (ACN 003 252 275  ABN 91 003 252 275)
GPO Box 3411
Sydney NSW  2001
Australia
E-mail:  [EMAIL PROTECTED]


--
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-help@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.


[R] Using metric units in plots

2008-06-20 Thread Philip Rhoades

People,

It appears that one has to use Imperial measurements in plot parameters? 
 I can't find any info on using metric units . .


Thanks,

Phil.
--
Philip Rhoades

Pricom Pty Limited  (ACN 003 252 275  ABN 91 003 252 275)
GPO Box 3411
Sydney NSW  2001
Australia
E-mail:  [EMAIL PROTECTED]

__
R-help@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.