Re: [R] Legend problem when exporting a plot to PDF

From: Philipp Pagel <>
Date: Tue, 29 Apr 2008 13:49:01 +0200

> 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)



Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
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

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 29 Apr 2008 - 12:06:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 Apr 2008 - 14:30:32 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive