[R] Trellis devices and pointize

Patrick Connolly p_connolly at slingshot.co.nz
Thu Jun 12 11:01:20 CEST 2014


On Mon, 09-Jun-2014 at 08:33AM +0100, Prof Brian Ripley wrote:

|> The issue here is not trellis.device.
|> 
|> You are using lattice plots (without mentioning lattice), which are
|> based on package 'grid' and so using the grid sub-system of a
|> device. That sub-system does not use the 'pointsize' of the device
|> as its initial font size.  So you need to use
|> 
|> grid::gpar(fontsize = 28)
|> 
|> If I call that after opening the device I get what I guess you expected.

I don't see it making any difference at all.  At one time I supposed that some clever inner
workings rescaled everything to something more sensible for a plotting
region that size, but that is not the case.

>   trellis.device(device = pdf, file = "Singers.pdf", height = 160/25.4,
+                  width = 160/25.4)

> grid::get.gpar()$fontsize
[1] 12
> grid::gpar(fontsize = 8)
$fontsize
[1] 8

> grid::get.gpar()$fontsize
[1] 12
>   

Evidently I missed something somewhere.  Grid graphics is sometimes a
bit too subtle for me.  I know gpar() doesn't work exactly analogously
to the way par() works.  I can't find any examples in Paul's "R
Graphics" book or Deepayan's "Lattice" book (but that might just be
lack of searching skills).

Then I tried putting it in the call to print.trellis:

  print(pik, plot.args = grid::gpar(fontsize = 8))

and in the bwplot() call similar to the way I'd done in panel functions
with an argument called gp but I get no error message or any
difference in my resulting plot.

I know I can fiddle with trellis.par.get() and trellis.par.set() but
that's a bit long-winded when it's so simple to do in base graphics.

TA

|> 
|> 
|> On 09/06/2014 07:54, Patrick Connolly wrote:
|> >How is the pointsize set in trellis.devices?
|> >
|> >>From my reading of the trellis.device help file, I understood that the
|> >pointsize arg would be referenced to the call to the pdf function.
|> >
|> >So I set up a trellis pdf device as so:
|> >
|> >   trellis.device(device = pdf, file = "Singers.pdf", height = 160/25.4,
|> >                  width = 160/25.4, pointsize = 28)
|> >
|> >A base R graphics plot works as I'd expected.
|> >
|> >   plot(1:10, 50:59) # silly plot with huge plotting characters and letters
|> >
|> >However, pointsize is ignored in trellis plots;
|> >
|> >   pik <- bwplot(voice.part ~ height, data = singer)# pointsize ignored
|> >   print(pik)
|> >   dev.off()
|> >
|> >There are many trellis cex-type settings, but FWIU they're all
|> >relative to the default size.  My question is: How do I set that
|> >default?
|> >
|> >
|> >R version 3.0.2 (2013-09-25)
|> >Platform: i686-pc-linux-gnu (32-bit)
|> >
|> >locale:
|> >  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
|> >  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
|> >  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
|> >  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
|> >  [9] LC_ADDRESS=C               LC_TELEPHONE=C
|> >[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
|> >
|> >attached base packages:
|> >[1] grDevices utils     stats     graphics  methods   base
|> >
|> >other attached packages:
|> >[1] RColorBrewer_1.0-5 lattice_0.20-24
|> >
|> >loaded via a namespace (and not attached):
|> >[1] grid_3.0.2  plyr_1.8    tools_3.0.2
|> >
|> >I've tried with R-3.1.0 on another machine so I don't think the
|> >problem is with an old version.
|> >
|> >I doubt it has much to do with pdf specifically.  Attempts to use png,
|> >bitmap, postscript devices all produce equivalent results.
|> >
|> >
|> >
|> >(Here's all the example code uninterrupted:)
|> >
|> >   trellis.device(device = pdf, file = "Singers.pdf", height = 160/25.4,
|> >                  width = 160/25.4, pointsize = 28)
|> >   plot(1:10, 50:59) # silly plot with huge plotting characters and letters
|> >   pik <- bwplot(voice.part ~ height, data = singer)# pointsize ignored
|> >   print(pik)
|> >   dev.off()
|> >
|> >
|> >TIA
|> >
|> >
|> 
|> 
|> -- 
|> Brian D. Ripley,                  ripley at stats.ox.ac.uk
|> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
|> University of Oxford,             Tel:  +44 1865 272861 (self)
|> 1 South Parks Road,                     +44 1865 272866 (PA)
|> Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                   Great minds discuss ideas    
 _( Y )_  	         Average minds discuss events 
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)  	                      ..... Eleanor Roosevelt
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.



More information about the R-help mailing list