1

I couldn't find any solution for adding horizontal space between two plots in pgfplots. The xshift thing didn't help. Here's the code:

\documentclass{sigplanconf}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usetikzlibrary{patterns}
\newcommand{\benchmark}{\textsf}
\usepgfplotslibrary{groupplots}
\usepackage{tikz}

\begin{document}

\pgfplotstableread{
1   identityOnly    both    otherOnly   average
a   0.00035173  0.00000422  0.00924541  0.12608777
b   0.00414079  0.00004965  0.10757113  0.00710518
c   0.00151162  0.00001813  0.04330784  0.13753664
d   0.00217766  0.00002526  0.06139371  0.00758067
e   0.00020642  0.00000249  0.00522527  0.00284578
f   0.00031703  0.00000380  0.02087894  0.00136650
g   0.00027212  0.00000324  0.00792774  0.00048840
h   0.10207314  0.00117326  2.63160651  0.22854330
i   0.05835732  0.00069973  1.47180476  0.34421183
j   0.00037218  0.00000434  0.01114818  0.00066935
y   0.03092297  0.00076165  1.36742588  0.09255707
}\america

\pgfplotstableread{
2   identityOnly    both    otherOnly   average
a   0.00177559  0.00003829  0.01138671  0.59759797
b   0.00234154  0.00004846  0.01488595  0.03278631
c   0.18083768  0.00392767  1.16344514  0.48364955
d   0.01192064  0.00026252  23.04508701 0.34154430
e   0.00642905  0.00013141  0.04140265  0.61546999
f   0.00331963  0.00008098  0.02224024  0.18646432
g   0.00325105  0.00006975  0.02156987  0.00076972
h   0.00220147  0.00004353  0.01544681  0.00065892
i   0.48762922  0.01007653  3.16949441  0.11817139
j   0.00368832  0.00007947  0.02380314  0.00196147
z   0.00385464  0.00212952  0.666095    0.494621
}\europe


\begin{figure}  
\centering
\begin{minipage}{0.45\columnwidth}
\centering
\begin{tikzpicture}[scale = .5, transform shape]
\begin{axis}[
 ybar stacked,
 axis x line*=bottom, 
 symbolic x coords={a,b,c,d,e,f,g,h,i,j,y},
 ymin=0, 
 xticklabel = {\benchmark{\tick}},
 yticklabel={ $\pgfmathprintnumber{\tick}\,\%$ },
 xtick=data,
 x tick label style={rotate=45,anchor=east,font=\Large},
 y tick label style={font=\Large},
 title style={font=\Large},
 xtick align=outside,
 ytick align=inside,
 every node near coord/.append style = {
   anchor = west, yshift = -2pt,
   rotate = 90,
   font = {\Large},
   /pgf/number format/fixed,
 }, title={1},
 cycle list = {
   { fill = gray },
   { fill = darkgray },
   { fill = lightgray },
 }]
 \addplot table [x index=0, y index =1] {\america};
 \addplot table [x index=0, y index =2] {\america};
 \addplot+[nodes near coords, point meta=explicit] table [x index=0, y index =3, meta index=4] {\america};
\end{axis}
\end{tikzpicture}
\end{minipage}
\begin{minipage}{0.45\columnwidth}
\centering
\begin{tikzpicture}[scale = .5, transform shape]
\begin{axis}[
 xshift=3mm, ybar stacked,
 axis x line*=bottom, 
 symbolic x coords={a,b,c,d,e,f,g,h,i,j,z},
 ymin=0, 
 xticklabel = {\benchmark{\tick}},
 yticklabel={ $\pgfmathprintnumber{\tick}\,\%$ },
 xtick=data,
 x tick label style={rotate=45,anchor=east,font=\Large},
 y tick label style={font=\Large},
 title style={font=\Large},
 xtick align=outside,
 every node near coord/.append style = {
   anchor = west,    rotate = 90,
   font = {\Large},
   /pgf/number format/fixed,
 }, title={2},
 cycle list = {
   { fill = gray },
   { fill = darkgray },
   { fill = lightgray },
 }]
 \addplot table [x index=0, y index =1] {\europe};
 \addplot table [x index=0, y index =2] {\europe};
 \addplot+[nodes near coords, point meta=explicit] table [x index=0, y index =3, meta index=4] {\europe};

\end{axis}
\end{tikzpicture}
\end{minipage}
\label{fig:hashed-objects2}
\end{figure}
\end{document}

It produces the following plot: enter image description here

I want to add more horizontal space between the two. I've already read this Using pgfplots, add vertical/horizontal spacing between plots?, but in my case I have different scales on y axis and I've read this How can I add space between two separate plots, using pgfplots? it also didn't help. I'm fighting the problem already for hours.. Would appreciate your help.

bekon
  • 449

1 Answers1

2

Try making both minipages a little bit wider, 0.5\columnwidth, and removing the space between them by adding a %, i.e.

\end{minipage}%  <-- % here removes a space
\begin{minipage}{0.5\columnwidth}

Both figures are a little wider than the minipage they are in, by giving them a little more room I get a little more space between the plots.

Torbjørn T.
  • 206,688
  • It did help! Actually, before I was giving more space for the minipage: \begin{minipage}{0.5\columnwidth}, however plots were placed in different rows. I didn't know about the %, it did the magic! Thanks! – bekon Aug 15 '13 at 09:34
  • @bekon No problem, glad it helped. For more about end-of-line %, see the questions that are linked to here: http://meta.tex.stackexchange.com/a/2429/586 – Torbjørn T. Aug 15 '13 at 09:44