[R] grImport symbols
baptiste.auguie at googlemail.com
Sun Jul 31 01:03:35 CEST 2011
I have two questions regarding grid.symbols() in the grImport package.
This package allows you to import a vector graphic in R, and
grid.symbols() can be used to plot the resulting glyph at arbitrary
locations in a grid viewport.
I have tried the code in the grImport vignette, which is most
interesting, however I am stuck with two problems:
1- Is there a possibility to create a Picture object directly from R
without importing an external image, but rather specified as a regular
grob/gTree, say. I would like to imitate my.symbols from
TeachingDemos, but with grid.
2- I could not figure out what the size argument in grid.symbols()
does. The following example fails rather curiously.
petal.ps <- "%!PS
newpath % start a new shape
0 0 moveto % move to a start location
-5 10 lineto % line to a new location
-10 20 10 20 5 10 curveto % curve to a third location
5 10 lineto % line to a fourth location
closepath % connect back to the start location
0 setgray % set the drawing colour to black
fill % fill the current shape"
petal <- readPicture("petal.ps.xml")
grid.symbols(petal, 1:10/10, 1:10/10, size=0.1) # OK
grid.symbols(petal, 1:10/10, 1:10/10, size = seq(0.01, 0.1,
length=10)) # Warning and weird shapes
R version 2.13.1 (2011-07-08)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)
attached base packages:
 stats graphics grDevices utils datasets grid
other attached packages:
 grImport_0.7-3 XML_3.4-0 ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4
loaded via a namespace (and not attached):
More information about the R-help