[R] ggplot2: font size mismatch for pdf output

Michael Friendly friendly at yorku.ca
Mon May 12 16:57:46 CEST 2008


Sorry for not providing this in my initial posting.
I'm using R version 2.7.0 (2008-04-22), on Win XP Pro.

As I said, the .png output matched what I saw on screen.
It was the .pdf output for which the font size was noticeably
larger, enough to make the legend run off the screen.

-Michael

Prof Brian Ripley wrote:
> 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.
>>
> 


-- 
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA



More information about the R-help mailing list