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?