6

I use R and ggplot2 to produce graphs for my thesis. I can port them to tikz objects using the tikzdevice or to a pdf using the pdf device very easily, and in each case, specifying the width and height of the overall plot is straightforward.

However, I am actually more interested in specifying the width of the plot AREA (ie the inner box), since differences in this (particularly for plots on the same page) are more easily detected by the eye, even if they are a couple of points different in the final document.

Of course, the source of this issue can be easily put down to the axis labels that vary depending on the content.

My question is, How can I define 'fixed' axis label widths as a global option, or define the width to be exported as the inner plotting area for ggplot2 objects....

Nicholas Hamilton
  • 10,044
  • 6
  • 57
  • 88
  • 3
    try [this hack](https://gist.github.com/baptiste/2877821): `set_panel_size(p, width=unit(7, "in"))` – baptiste Jun 19 '13 at 00:27
  • Thanks, that gets the areas the same width, but how can I make the right margin the same as the left margin (including tick labels) so that when the two plots are put in a centered environment, they line up. At the moment they are slightly offset. – Nicholas Hamilton Jun 19 '13 at 00:51
  • you need to play with the gtable, it should be straight-forward with that example – baptiste Jun 19 '13 at 00:55
  • What is the difference between g$widths[[2]] and g$widhts[[3]], ie what margin items do they relate to, g$widths[[5]] is the right margin, so need to set it to one of g$widths[[2]] or g$widths[[3]] as far as I can tell... – Nicholas Hamilton Jun 19 '13 at 01:38
  • `g$layout` will tell you what the viewports are meant to contain (ytitle, yaxis, panel, guide, I believe) – baptiste Jun 19 '13 at 10:48

0 Answers0