[R] draw a 5cm x 3cm rectangle
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Thu Oct 16 18:33:56 CEST 2008
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
More information about the R-help
mailing list