[R] Legend problem when exporting a plot to PDF

Philipp Pagel p.pagel at wzw.tum.de
Tue Apr 29 13:49:01 CEST 2008


> When exporting to PDF a graph with a legend, in the final PDF, the
> text  is going beyond the legend box.
> > dev2bitmap("test.pdf", type="pdfwrite", h=6, w=6)
> The legend looks OK on the screen.  I noticed that the size of the
> legend box depends on the size of the  screen window,

As far as I remember, te problem has to do with different font handling
in different devices. I'm sure someone more familiar wiht the internals
will comment on this.

The fix is easy: don't use dev2bitmap but open the desired target device
before plotting. In your case: 

pdf(file='test.pdf', width=6, height=6)
plot(...)
legend(...)
dev.off()

cu
	Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
 
 and
 
Institut für Bioinformatik und Systembiologie / MIPS
Helmholtz Zentrum München -
Deutsches Forschungszentrum für Gesundheit und Umwelt
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel



More information about the R-help mailing list