[R] ggplot2: font size mismatch for pdf output

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon May 12 16:38:14 CEST 2008


What version of R and OS is this?  Prior to R 2.7.0 there was little 
attempt to match output dimensions from various devices, and one of the 
png devices in 2.7.0 has an error in doing so, fixed in R-patched (see 
NEWS).

On Mon, 12 May 2008, Michael Friendly wrote:

> Hi
>
> In the following, the graph I see on the screen and the .png output
> coincide.  However, in the .pdf file, the fonts seem to be scaled
> fairly larger, resulting in the label for the top legend disappearing.
> Is this an infelicity or bug, or is there something I've missed?
>
> More generally, how do I control the size of fonts used in legends
> and axis labels?
>
> library(car)
> library(ggplot2)
>
> qp <-qplot (education , income , shape=type , size=women , colour=prestige ,
> 	 xlab="Education" , ylab="Income", data=Prestige)
>   + scale_y_continuous(limits=c(NA, 20000))

Hmm, you can't break the line before '+'.

> qp + scale_size(to=c(1,8))
>
> ggsave(file="prestige-ggplot.png", width=6, height=5)  # OK
> ggsave(file="prestige-ggplot.pdf", width=6, height=5)  # fonts too large

I would not expect you to be able to specify a smaller size without also 
reducing 'pointsize'.  E.g. dev.print() does so, but ggsave seems not to.

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