[R] draw a 5cm x 3cm rectangle

Greg Snow Greg.Snow at imail.org
Thu Oct 16 18:49:06 CEST 2008


Add to that list the functions grconvertX and grconvertY which can take coordinates in many different units and convert them to others (including inches, then just multiply/divide by 2.54 for the conversion from/to cm).

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Barry Rowlingson
> Sent: Thursday, October 16, 2008 10:34 AM
> To: Thomas Steiner
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] draw a 5cm x 3cm rectangle
>
> 2008/10/16 Thomas Steiner <finbref.2006 at gmail.com>:
> > Hi I want to draw sth in a pdf file with a predefined defined size.
> > Say a 5cm x 3cm rectangle (a ruler):
> >
> > pdf("rect.pdf", paper="a4")
> > plot(c(1,5,5,1,1),c(1,1,3,3,1),asp=1,axes="n")
> > dev.off()
> >
> > but how do I fix that one unit is 1cm?
>
>  I just did help.search("inch") and found xinch:
>
>      'xinch' and 'yinch' convert the specified number of inches given
>      as their arguments into the correct units for plotting with
>      graphics functions.  Usually, this only makes sense when normal
>      coordinates are used, i.e., _no_ 'log' scale (see the 'log'
>      argument to 'par').
>
>  Then help.search("cm") gave me cm:
>
> Description:
>
>      Translates from inches to cm (centimeters).
>
>  You just need the inverse of this. Not too hard.
>
>  Also, the symbol() function takes an inches=TRUE parameter that lets
> you specify inches as the object size.
>
>  The grid graphics package has a units system as well, but I've not
> played with that. See help("unit") for info.
>
> Barry
>
> ______________________________________________
> 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.



More information about the R-help mailing list