Re: [R] textbox in lattice

2010-06-08 Thread Paul Murrell


Shifting this to r-devel ...

On 6/6/2010 11:20 PM, baptiste auguie wrote:

Hi,

I've just added width/heightDetails methods following Paul's
suggestion. I kept a duplicate of all on-the-fly grob size
calculations; it is necessary to ensure that the table cells adjust to
the content which can be subsequently edited (e.g changing the
colnames to plotmath expressions). Drawing the full iris dataset (150
x 5) takes 12 seconds when it was 8 seconds before. It is still
reasonable; I don't think anyone would want to use it for huge tables
anyway.

Out of curiosity, could drawDetails and height/widthDetails be altered
to share some information (thereby avoiding such duplication of
calculations at drawing time), or do they have to be completely
independent in the implementation?

Best,

baptiste

On 3 June 2010 07:58, baptiste auguiebaptiste.aug...@googlemail.com  wrote:

Hi,

On 3 June 2010 05:26, Paul Murrellp.murr...@auckland.ac.nz  wrote:


Or the same drawing calculations have to be repeated within
width/heightDetails - those methods should get run within the same graphical
context as the drawDetails method.



Yes, the idea crossed my mind, but I did not find it very appealing
(already the function is slower than it could/should be). Something to
consider though, in a future version.

Thanks,

baptiste






Paul


Best,

baptiste

__
R-help@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 Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/





--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
R-help@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.


Re: [R] textbox in lattice

2010-06-06 Thread baptiste auguie
Hi,

I've just added width/heightDetails methods following Paul's
suggestion. I kept a duplicate of all on-the-fly grob size
calculations; it is necessary to ensure that the table cells adjust to
the content which can be subsequently edited (e.g changing the
colnames to plotmath expressions). Drawing the full iris dataset (150
x 5) takes 12 seconds when it was 8 seconds before. It is still
reasonable; I don't think anyone would want to use it for huge tables
anyway.

Out of curiosity, could drawDetails and height/widthDetails be altered
to share some information (thereby avoiding such duplication of
calculations at drawing time), or do they have to be completely
independent in the implementation?

Best,

baptiste

On 3 June 2010 07:58, baptiste auguie baptiste.aug...@googlemail.com wrote:
 Hi,

 On 3 June 2010 05:26, Paul Murrell p.murr...@auckland.ac.nz wrote:

 Or the same drawing calculations have to be repeated within
 width/heightDetails - those methods should get run within the same graphical
 context as the drawDetails method.


 Yes, the idea crossed my mind, but I did not find it very appealing
 (already the function is slower than it could/should be). Something to
 consider though, in a future version.

 Thanks,

 baptiste





 Paul

 Best,

 baptiste

 __
 R-help@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 Paul Murrell
 Department of Statistics
 The University of Auckland
 Private Bag 92019
 Auckland
 New Zealand
 64 9 3737599 x85392
 p...@stat.auckland.ac.nz
 http://www.stat.auckland.ac.nz/~paul/



__
R-help@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.


Re: [R] textbox in lattice

2010-06-03 Thread baptiste auguie
Hi,

On 3 June 2010 05:26, Paul Murrell p.murr...@auckland.ac.nz wrote:

 Or the same drawing calculations have to be repeated within
 width/heightDetails - those methods should get run within the same graphical
 context as the drawDetails method.


Yes, the idea crossed my mind, but I did not find it very appealing
(already the function is slower than it could/should be). Something to
consider though, in a future version.

Thanks,

baptiste





 Paul

 Best,

 baptiste

 __
 R-help@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 Paul Murrell
 Department of Statistics
 The University of Auckland
 Private Bag 92019
 Auckland
 New Zealand
 64 9 3737599 x85392
 p...@stat.auckland.ac.nz
 http://www.stat.auckland.ac.nz/~paul/


__
R-help@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.


Re: [R] textbox in lattice

2010-06-02 Thread baptiste auguie
On 2 June 2010 07:55, Deepayan Sarkar deepayan.sar...@gmail.com wrote:


 Something like this should also work, except that the grob produced by
 tableGrob() doesn't seem to know its height.

Indeed, I have not been successful in writing good
widthDetails/heightDetails methods for this grob since all the drawing
calculations are made in the drawDetails method. Maybe some of these
calculations don't really need to be made at drawing time.

Best,

baptiste

__
R-help@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.


Re: [R] textbox in lattice

2010-06-02 Thread Paul Murrell

Hi

On 2/06/2010 7:33 p.m., baptiste auguie wrote:

On 2 June 2010 07:55, Deepayan Sarkardeepayan.sar...@gmail.com  wrote:



Something like this should also work, except that the grob produced by
tableGrob() doesn't seem to know its height.


Indeed, I have not been successful in writing good
widthDetails/heightDetails methods for this grob since all the drawing
calculations are made in the drawDetails method. Maybe some of these
calculations don't really need to be made at drawing time.


Or the same drawing calculations have to be repeated within 
width/heightDetails - those methods should get run within the same 
graphical context as the drawDetails method.


Paul


Best,

baptiste

__
R-help@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 Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
R-help@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.


Re: [R] textbox in lattice

2010-06-01 Thread baptiste auguie
Hi,

It's not clear what you mean by summary text without a minimal
reproducible example. If your text is ordered as a matrix or a
data.frame, you might want to try this grid function,

gridExtra::grid.table(as.matrix(summary(iris)), theme=theme.white())

If your text has the form of a paragraph, the RGraphics::splitTextGrob
function might help.

HTH,

baptiste



On 1 June 2010 19:37, Noah Silverman n...@smartmediacorp.com wrote:
 Hi,

 I want to add a box at the bottom of a lattice window (device/page?).

 Lattice has drawn a nice group of panels with all the plots I need.  How
 do I add my own summary text at the bottom (several lines worth?)

 __
 R-help@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.


__
R-help@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.


Re: [R] textbox in lattice

2010-06-01 Thread Noah Silverman
Hi,

It is a matrix.  Exactly the output of summary(foo)

Would you call the gridExtra command before the xyplot command or after?

Now I have:

temp - as.mcmc(foo)
xyplot(temp, layout=c(2,11), main=plot title)


THANKS!!


On 6/1/10 11:35 AM, baptiste auguie wrote:
 Hi,

 It's not clear what you mean by summary text without a minimal
 reproducible example. If your text is ordered as a matrix or a
 data.frame, you might want to try this grid function,

 gridExtra::grid.table(as.matrix(summary(iris)), theme=theme.white())

 If your text has the form of a paragraph, the RGraphics::splitTextGrob
 function might help.

 HTH,

 baptiste



 On 1 June 2010 19:37, Noah Silverman n...@smartmediacorp.com wrote:
   
 Hi,

 I want to add a box at the bottom of a lattice window (device/page?).

 Lattice has drawn a nice group of panels with all the plots I need.  How
 do I add my own summary text at the bottom (several lines worth?)

 __
 R-help@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.



__
R-help@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.


Re: [R] textbox in lattice

2010-06-01 Thread Noah Silverman
That's amazing.  (It would have taken me many hours to figure this out
on my own.)

Two quick last questions and then I'm off to plotting:
1) How can I reduce the font size of the table. (It is huge on my plot.)
2) How can I control the ratio of plot area to table area in the grid?

Thanks a million!

-N


On 6/1/10 12:07 PM, baptiste auguie wrote:
 Please do read the posting guide, in particular regarding reproducible 
 examples.

 You can use a Grid layout to place the lattice plot and a table in the
 same page. For example,

 library(lattice)
  library(coda)
  library(gridExtra)
x - matrix(runif(2200),ncol=22)
m - as.mcmc(x)
   p = xyplot(m, layout = c(2, 11))

  pdf(,height=15)
  arrange(p, tableGrob(as.matrix(summary(iris)), theme=theme.white()),
 heights= unit(c(3,1),null))
  dev.off()

 HTH,

 baptiste
 On 1 June 2010 20:52, Noah Silverman n...@smartmediacorp.com wrote:
   
 Hi,

 It is a matrix.  Exactly the output of summary(foo)

 Would you call the gridExtra command before the xyplot command or after?

 Now I have:

 temp - as.mcmc(foo)
 xyplot(temp, layout=c(2,11), main=plot title)


 THANKS!!


 On 6/1/10 11:35 AM, baptiste auguie wrote:
 
 Hi,

 It's not clear what you mean by summary text without a minimal
 reproducible example. If your text is ordered as a matrix or a
 data.frame, you might want to try this grid function,

 gridExtra::grid.table(as.matrix(summary(iris)), theme=theme.white())

 If your text has the form of a paragraph, the RGraphics::splitTextGrob
 function might help.

 HTH,

 baptiste



 On 1 June 2010 19:37, Noah Silverman n...@smartmediacorp.com wrote:

   
 Hi,

 I want to add a box at the bottom of a lattice window (device/page?).

 Lattice has drawn a nice group of panels with all the plots I need.  How
 do I add my own summary text at the bottom (several lines worth?)

 __
 R-help@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.




__
R-help@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.


Re: [R] textbox in lattice

2010-06-01 Thread Erik Iverson



Noah Silverman wrote:

That's amazing.  (It would have taken me many hours to figure this out
on my own.)

Two quick last questions and then I'm off to plotting:
1) How can I reduce the font size of the table. (It is huge on my plot.)
2) How can I control the ratio of plot area to table area in the grid?


For 1), you usually specify something like

textGrob(... , gp = gpar(cex = .8))

For 2), you may have to use something other than arrange, like creating 
your own grid viewport and using grid.layout.


For the long term, I would suggest getting a copy of the book 'R 
Graphics', which will get you very familiar with all these concepts and 
much more!


__
R-help@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.


Re: [R] textbox in lattice

2010-06-01 Thread Deepayan Sarkar
On Wed, Jun 2, 2010 at 12:37 AM, baptiste auguie
baptiste.aug...@googlemail.com wrote:
 Please do read the posting guide, in particular regarding reproducible 
 examples.

 You can use a Grid layout to place the lattice plot and a table in the
 same page. For example,

 library(lattice)
  library(coda)
  library(gridExtra)
   x - matrix(runif(2200),ncol=22)
   m - as.mcmc(x)
  p = xyplot(m, layout = c(2, 11))

  pdf(,height=15)
  arrange(p, tableGrob(as.matrix(summary(iris)), theme=theme.white()),
 heights= unit(c(3,1),null))
  dev.off()

Something like this should also work, except that the grob produced by
tableGrob() doesn't seem to know its height.

splom(iris,
  sub = tableGrob(as.matrix(summary(iris)),
  gp=gpar(cex = 0.5)))

A quick alternative using lattice::draw.key() is

tableKey - function(x)
{
key - list()
for (i in 1:ncol(x))
{
labels - c(colnames(x)[i], x[,i])
font - c(2, rep(1, nrow(x)))
key - c(key, list(text = list(labels, font = font)))
}
draw.key(key, draw = FALSE)
}

splom(iris, sub = tableKey(as.matrix(summary(iris

-Deepayan

__
R-help@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.