Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I use ggplot2 to generate Tikz images which are placed on multiple pages of a LaTeX document. For consistency I'd like to center all of these plots, but the legends and axes can be a bit different in width from plot to plot. At the moment, the best I can do is set the entire Tikz output to be a certain width and that roughly makes my plots the same, but it's not perfect. Also centering the entire output means that it looks visually like it isn't centered due to the width of the legend on the right.

Right now I usually do something like:

tikz('plot.tex', standAlone = FALSE, width=5, height=3.5)

dodge = position_dodge(width=0.9)
limits = aes(ymax=BarMax,ymin=BarMin)
g1 = ggplot(duckmeans,aes(x=group,y=Estimate,group=MemoryTask)) + 
     geom_bar(aes(fill=MemoryTask),position="dodge",stat="identity") + 
     xlab("Interface") + ylab("Duck failure rate") + 
     opts(axis.text.x = theme_text(colour="black"), axis.text.y = theme_text(colour="black"), axis.title.x=theme_text(size=10), axis.title.y=theme_text(size=10, angle=90))
print(g1)
dev.off()

Is there a way to set a fixed-width plot region, which will be centered in the output with the legend and the axis labels drawn relative to that plot region?

share|improve this question
1  
This question would probably fit better at stackoverflow. (Nicely asked, though). – Drew Steen Apr 3 '12 at 16:04
That's off-topic here. Two possible solutions are tex.SE or Stackoverflow. I will migrate this question for you when I get some feedback from their respective mods. – chl Apr 3 '12 at 21:45

closed as off topic by Andy W, onestop, chl Apr 3 '12 at 22:09

Questions on Cross Validated are expected to relate to statistics within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.