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

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Apr 29 16:01:54 CEST 2008


You forgot to mention your version of R and your platform (and R has at 
least 3 separate png() devices).

In 2.7.0, specify the size in inches and increase the resolution.
In earlier versions, try bitmap().  From NEWS for 2.7.0

     o	Considerable efforts have been made to make the default output
 	from graphics devices as similar as possible (and in
 	particular close to that from postscript/pdf).	Many devices
 	were misinterpreting 'pointsize' in some way, for example as
 	being in device units (pixels) rather than in points.


On Tue, 29 Apr 2008, Xavier Chardon wrote:

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

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



More information about the R-help mailing list