Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

font size confusion in ggplot2

I'm working on a manuscript for a journal and the requirement is font size 10 for graphs. I tried this in R with ggplot2 with a setting like this:

p<-qplot(...)+theme_bw()
ggsave(filename="plot.pdf",plot=p,width=8,height=8,scale=1.3)

The x and y axis text in the figure looks really small.. I checked the R code for theme_bw() and i think the axis text font is the default 12 times 0.8, so roughly font 10. Is font size 10 in ggplot is really equal to font size 10 in Word or other context?

I've read this post: ggplot2 - The unit of size

And I'm also confused by whether the font size 100 used in the above post is actually 100 or 100/0.35277... which one is it?

Lastly, when I put the figure in Illustrator along with others in a panel, the resulting axis font looks pretty small. I kinda feel it's not font size 10 but it was generated with font size 10 specification in R.. Not sure if I should use a larger font to make it look bigger.

like image 773
olala Avatar asked Jul 21 '14 20:07

olala


1 Answers

Too long for a comment. I'm not sure I understand your question completely, so if this isn't helpful let me know and I'll delete it.

First of all width and height in ggsave(...) refers to the width and height of the image. The default units are inches, but this can be changed via the units=... argument. So in your code the image will be 8" by 8". If you view this in Acrobat Reader at 100%, the font sizes will be whatever you've set them to in ggplot (see below). But if you create an 8 X 8 image (which is pretty big) and then scale it down for inclusion in a paper, everything will get smaller. Said another way, if the image in you paper is physically 3 X 5 (as an example), then the call to gggsave(...) should reflect that.

Second, in ggplot you can set the size of the axis text (the tick mark labels), and the axis title (the axis label) separately. The default in theme_bw() is axis.title=12pt and axis.text=0.8*12pt. So if you want both the axis label and the tick mark labels to be 10pt, you need to specify:

theme_bw() + 
theme(axis.text=element_text(size=10),axis.title=element_text(size=10))
like image 69
jlhoward Avatar answered Nov 14 '22 13:11

jlhoward