[R] y-axis of lattice panels not printing to paper

Deepayan Sarkar deepayan at cs.wisc.edu
Thu Jul 1 21:40:44 CEST 2004


Quoting Pam Goodman <pgoodman at nwifc.org>:

> Greetings, 
> 
> I am printing lattice plots from the R-interface to a printer, and although
> the y-axes of the left-most panels are visable on the screen, they are not
> present on the paper when  there are multiple panels (ie, >1). 
> 
> For example:
> 
> trellis.device(bg='white')
> histogram(~dbh, data=diameter.df)
> 
> ###print to a printer from the R-interface by clicking the print button on
> the toolbar
> 
> The above prints fine. All axes intact. 
> 
> However, 
> trellis.device(bg='white')
> histogram(~dbh|species, data=diameter.df)
> 
> ###print to a printer from the R-interface by clicking the print button on
> the main toolbar
> 
> This second example does not have y-axes for the left-most panels. 
> 
> There is at least one work-around. For example, if I copy/paste as a metafile
> into Word, the axes are present in the printed document. However, I'm
> currently in the EDA phase, it's relatively more convenient to print directly
> to the printer, because in reality I have several graphs I am printing in a
> loop:
> 
> trellis.device(bg='white')
> for(i in 1:50){
>  print(histogram(~dbh|species.c, data=eval(parse(text=site.names.sort[i])), 
>  breaks=c(0,seq(4,92,by=2)), main=site.names.sort[i], type="density"))
> dev.copy()
> dev.print(device=win.print)
>  }
> 
> All 50 of the plots lack the y-axes in the left-most panels. Also, I tested
> xyplot(), and I get the same behavior. 
> 
> How can I get the y-axes of the left-most panels to be printed to the page? 

I have no idea what the problem is. Might it have something to do with paper
size? Does changing the size of your screen devices/win.print help?

I should mention that this is probably not a good way to print lattice graphs.
The settings for screen devices are not suitable for printing. I think there
are also more general issues with converting output of one device to another (I
don't understand all the details). In this situation, I would use 

trellis.device(pdf, file = "foo.pdf")
for(i in 1:50){
  print(histogram(~dbh|species.c, data=eval(parse(text=site.names.sort[i])), 
  breaks=c(0,seq(4,92,by=2)), main=site.names.sort[i], type="density"))
  }
dev.off()

and then print the PDF file.

Deepayan




More information about the R-help mailing list