[R] ggplot2: setting global graphic parameters with png driver

From: Xavier Chardon <xavier.chardon_at_rennes.inra.fr>
Date: Tue, 29 Apr 2008 15:05:12 +0200


Hi all,

I prepared a few charts with ggplot2, and was happy with the results as displayed on screen.
I tried to draw them with a PNG driver instead. But I ran into several problems while trying to increase the resolution of the picture.

Mainly, when I increased the picture size (e.g png(width=1024, height=768) ), the texts (title, labels, etc...) where too small. I tried to set the "pointsize" option of the driver. That did the trick, to some extent. But it seems limited, and I couldn't get big enough fonts for high resolution images. Also, I tried the "resolution" setting of the driver. But this has an effect on lots of things, e.g. the length of the lines in the legend, so I gave up this idea. I tried to change the font size of all elements, with e.g. grid.gedit("label", gp=gpar(cex=4) ). But the position of the labels does not change then, and with the bigger font, they are drawn on top of the axis or of its title.
Another problem was that the line width is also too small in big images. I couldn't find a way to change it globally.

So, is there a way to go easily from a plot that looks good on screen (X11 driver) to a similar png image? Or is it possible to change the default settings of ggplot2 (line size and font size in particular, which are not covered by the ggopt function) ? I guess people usually export their charts as image files, so hopefully there's an easy solution.

Many thanks,

Xavier



R-help_at_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. Received on Tue 29 Apr 2008 - 14:28:18 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 - 15:00:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive