Combining text and graphical output ... slightly off-topic

59 views
Skip to first unread message

Rob James

unread,
Sep 30, 2009, 2:29:04 PM9/30/09
to ggplot2
Slightly off topics, but relevant to making reliable graphics...

I'd like to produce a file that has both graphics and textual elements.

On page 1, for example, I'd like to have some textual information on
distributions - so that the graph - here Page 2 - is not disassociated
from the meta-data.

Clearly I can do that in Sweave, but I was trying not to involve another
step. Ideally I'd have a graphics driver that would also generate
text... However, the pdf driver in particular, won't take text - even
though the PDF format clearly will hold both text and graphics.

Murrell and Jornik (http://www.ci.tuwien.ac.at/Conferences/DSC-2003/)
write "Text-based output is only possible for certain graphics
devices,... " but they do not mention which graphics devices would
support both.C

Suggestions welcome.

baptiste auguie

unread,
Sep 30, 2009, 3:05:11 PM9/30/09
to Rob James, ggplot2
Hi,

I would still recommend the slight burden of Sweave, or alternatives such as:

- the brew package

- the ascii package

- odfSweave

- ... (there are probably others)


If you text (possibly with tables) is *very simple* though, you might
have some luck with custom grid functions. As an example,


library(RGraphics) # support of the "R graphics" book, on CRAN
library(gridextra) # experimental package, http://code.google.com/p/gridextra/

g1 <- tableGrob(head(iris))

string <- "
This famous (Fisher's or Anderson's) iris data set gives the
measurements in centimeters of the variables sepal length and width
and petal length and width, respectively, for 50 flowers from each of
3 species of iris. The species are Iris setosa, versicolor, and
virginica.
"

g2 <- splitTextGrob(string)
#"Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
g3 <- qplot(Sepal.Length, Petal.Length, data=iris, colour=Species)


arrange2(g1, g2, g3, ncol=1, main="The iris data")

The output is attached.

HTH,

baptiste
iris.pdf

Rob James

unread,
Sep 30, 2009, 3:59:04 PM9/30/09
to baptiste auguie, ggplot2
Baptiste,

Thanks for the ideas and the worked example. This was very helpful.

Perhaps it is just me, but I often look at a graph ad the titles, etc,
don't provide me with the information I need to have in order to
determine if the graph is "definitive". Date/time strings for datasets,
appropriate subsetting commands, etc. Other times I would like the
actual measures for something that I am showing on the graph, for
example IQRs when showing boxplots.

Your examples are very helpful.
Reply all
Reply to author
Forward
0 new messages