[R] ggplot2: setting global graphic parameters with png driver
Xavier Chardon
xavier.chardon at rennes.inra.fr
Tue Apr 29 15:05:12 CEST 2008
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
More information about the R-help
mailing list