Hello there,
could you please help to modify gpar() properties of a cell inside
tableGrob() output.
In the following example I want to have different color for one out of 4 cells
require(gridExtra)
z<-matrix(1:4,2,2)
grid.draw(tableGrob(z))
The only way I found for now how to do it is to do something like this
downViewport(current.vpTree()$children[[1]]$children[[6]]$name)
grid.text('2',gp=gpar(col='red',fontface='bold'))
But for some reasons when I try to print the table into jpeg the last
grid.text() prints desired label text somewhere but not in the place I
want it to be.
Is there another more "smart" way to do it?
Thanks in advance!
Kind regards,
Alex
tableGrob and properties of a cell
3 messages · Alex Bird, Baptiste Auguie
Hi,
Embarrassingly enough, it was quite straight-forward in the first
versions of grid.table(). You might want to try with version r11 for
example,
source("http://gridextra.googlecode.com/svn-history/r11/trunk/R/tableGrob.r")
library(grid)
tc = textConnection("
carat VeryLongWordIndeed color clarity depth
14513 1.35 Ideal J VS2 61.4
28685 0.30 Good G VVS1 64.0
50368 0.75 Ideal F SI2 59.2")
d = read.table(tc,head=T)
close(tc)
grid.newpage()
g = grid.table(d)
grid.ls(g)
grid.edit("top-head-fill-5", gp=gpar(fill="red"))
grid.edit("cells-label-33", label=expression(alpha),gp=gpar(col="orange"))
As I recall, the reason why this is more difficult now (if at all
possible, I have no idea), is that I placed the actual drawing code in
a drawDetails method, so that it gets updated on-the-fly, etc.
I hope this simpler version will suit you, I might re-include it in
the package as an alternative.
HTH,
baptiste
On 7 December 2010 16:53, Alex Bird <sunduck at gmail.com> wrote:
Hello there,
?could you please help to modify gpar() properties of a cell inside
tableGrob() output.
?In the following example I want to have different color for one out of 4 cells
require(gridExtra)
z<-matrix(1:4,2,2)
grid.draw(tableGrob(z))
?The only way I found for now how to do it is to do something like this
downViewport(current.vpTree()$children[[1]]$children[[6]]$name)
grid.text('2',gp=gpar(col='red',fontface='bold'))
But for some reasons when I try to print the table into jpeg the last
grid.text() prints desired label text somewhere but not in the place I
want it to be.
Is there another more "smart" way to do it?
Thanks in advance!
Kind regards,
Alex
______________________________________________ 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.
____________________ Dr. Baptiste Augui? Departamento de Qu?mica F?sica, Universidade de Vigo, Campus Universitario, 36310, Vigo, Spain tel: +34 9868 18617 http://webs.uvigo.es/coloides