2
votes

I have create some ggplot2 bar plots which print fine to screen. When I print in PDF device, however, the chart and axis titles are too large - they sometimes extend past the left and right of the x-axis. None of these charts have any opts() set aside from title/axis-title - its all the defaults. What am I missing here? Is there a way to tell ggplot to auto-size this text so that the charts look good in PDF? Can I do this without explicitly setting opts()?

1
try changing the pointsize parameter in pdf(). this sometimes works.Seb
I think that's the same as par(ps=... ). I tried pointsize in pdf() and the plots don't change. Strangely, its using 14 point size where my ps/pointsize is 12. Not sure how it determines 14SFun28
I think the 14 is the result of the default theme which I think multiplies the base font size by 1.2. It seems that I could fix this with the right theme, but I'd have to detect the size of the plotting region and the text itself to determine the parameters for the theme...was hoping for something out-of-the-boxSFun28
Depending on your use, you could also use the height and width parameters of pdf to make the canvas biggerGregor Thomas
Thanks. I'm writing to a standard PDF size for printing, so I don't think that will helpSFun28

1 Answers

0
votes

The best solution I can think of is to create a function to create a theme (like theme_bw()) and give it enough parameters so that its smart about sizing. Will keep this post open for a few days to see if there are any other clever ideas