0

I'm newer to latex and pgfplots, and have a question on how I can position multiple tikzpicture in a single figure. In my example, there are 15 tikzpicture in the figure - 3 rows and 5 columns. How can I align them (both vertically and horizontally), and how can I reduce the distance (both vertically and horizontally) between them such that there are only a few pixels separating the tikzpicture boxes? Thanks! enter image description here

\begin{figure*}

%%%%%%%%%%%%%%%%%%%
% NN Naive Comparison
%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Factor Faster
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%
% vary cluster size
%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={,,},
ybar,
ymin=0.1, ymax=130,
ytick={1,10,100},
ymajorgrids=true,
ylabel={Speedup Fact.},
}

\begin{axis} [bar width = 0.30cm,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=blue!60,]
coordinates {(1,9.1)(2,18.4)(3,16.0)(4,11.8)(5,7.6)};
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary straightness factor
%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={,,},
ybar,
ymin=0.1, ymax=130,
ytick={1,10,100},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.30cm,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=blue!60,]
coordinates {(1,24.8)(2,22.0)(3,18.7)(4,18.4)(5,16.3)};
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary avg number vertices
%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={,,},
ybar,
ymin=0.1, ymax=130,
ytick={1,10,100},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.30cm,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=blue!60,]
coordinates {(1,18.4)(2,17.5)(3,15.1)(4,13.4)(5,12.3)};
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary input trajectory size
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={,,},
ybar,
ymin=0.1, ymax=130,
ytick={1,10,100},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.30cm,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=blue!60,]
coordinates {(1,18.4)(2,28.1)(3,43.5)(4,59.7)(5,69.8)};
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary dimension size
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={,,},
ybar,
ymin=0.1, ymax=130,
ytick={1,10,100},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.30cm,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=blue!60,]
coordinates {(1,18.4)(2,18.7)(3,15.3)(4,9.6)(5,8.8)};
\end{axis}

\end{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Number Constant LB Computations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%
% vary cluster size
%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={,,},
ybar,
ymin=0.02, ymax=15,
ytick={0.1,1,10},
ymajorgrids=true,
ylabel={\# Const. LB $\cdot 10^3$},
}

\begin{axis} [bar width = 0.15cm,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=blue!60,bar shift = -0.1cm,]
coordinates {(1,0.13)(2,0.05)(3,0.05)(4,0.07)(5,0.09)};
\addplot[color=black,fill=black!80,bar shift = 0.1cm,]
coordinates {(1,5)(2,5)(3,5)(4,5)(5,5)};
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary straightness factor
%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={,,},
ybar,
ymin=0.02, ymax=15,
ytick={0.1,1,10},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.15cm, bar shift = -0.1cm,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=blue!60,]
coordinates {(1,0.04)(2,0.04)(3,0.05)(4,0.05)(5,0.06)};
\end{axis}

\begin{axis} [bar width = 0.15cm, bar shift = 0.1cm, hide axis,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=black!80,]
coordinates {(1,5)(2,5)(3,5)(4,5)(5,5)};
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary avg number vertices
%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={,,},
ybar,
ymin=0.02, ymax=15,
ytick={0.1,1,10},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.15cm, bar shift = -0.1cm,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=blue!60,]
coordinates {(1,0.05)(2,0.05)(3,0.05)(4,0.06)(5,0.06)};
\end{axis}

\begin{axis} [bar width = 0.15cm, bar shift = 0.1cm, hide axis,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=black!80,]
coordinates {(1,5)(2,5)(3,5)(4,5)(5,5)};
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary input trajectory size
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={,,},
ybar,
ymin=0.02, ymax=15,
ytick={0.1,1,10},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.15cm, bar shift = -0.1cm,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=blue!60,]
coordinates {(1,0.05)(2,0.07)(3,0.09)(4,0.10)(5,0.12)};
\end{axis}

\begin{axis} [bar width = 0.15cm, bar shift = 0.1cm, hide axis,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=black!80,]
coordinates {(1,5)(2,5)(3,5)(4,5)(5,5)};
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary dimension size
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={,,},
ybar,
ymin=0.02, ymax=15,
ytick={0.1,1,10},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.15cm, bar shift = -0.1cm,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=blue!60,]
coordinates {(1,0.05)(2,0.06)(3,0.08)(4,0.14)(5,0.16)};
\end{axis}

\begin{axis} [bar width = 0.15cm, bar shift = 0.1cm, hide axis,
ymode = log,
log ticks with fixed point,
log origin = infty,
]
\addplot[color=black,fill=black!80,]
coordinates {(1,5)(2,5)(3,5)(4,5)(5,5)};
\end{axis}

\end{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Number Linear LB/UB Computations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%
% vary cluster size
%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xlabel={Cluster Size},
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={1,10,25,50,100},
ybar,
ymin=0, ymax=90,
ytick={5,20,40,60,80},
ymajorgrids=true,
ylabel={\# Lin. LB/UB},
}

\begin{axis} [bar width = 0.15cm, bar shift = -0.1cm,]
\addplot[color=black,fill=blue!60,]
coordinates {(1,3.46)(2,4.39)(3,9.50)(4,15.95)(5,33.27)};
\end{axis}

\begin{axis} [bar width = 0.15cm, bar shift = 0.1cm, hide axis,]
\addplot[color=black,fill=black!80,]
coordinates {(1,16.86)(2,46.79)(3,51)(4,55.98)(5,84.89)};
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary straightness factor
%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
legend pos=north east,
legend columns = 2,
xlabel={Straightness Factor},
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={0.5,0.8,0.9,.95,.99},
ybar,
ymin=0, ymax=90,
ytick={5,20,40,60,80},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.15cm,]
\addplot[color=black,fill=blue!60,bar shift = -0.1cm,]
coordinates {(1,3.82)(2,4.22)(3,4.62)(4,4.39)(5,5.06)};
\addplot[color=black,fill=black!80,bar shift = 0.1cm,]
coordinates {(1,42.9)(2,40.18)(3,39.38)(4,46.79)(5,39.43)};
\legend{$CCT$}
\addlegendentry{Naive}
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary avg number vertices
%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xlabel={Num. Vertices $n$},
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={15,25,35,45,55},
ybar,
ymin=0, ymax=90,
ytick={5,20,40,60,80},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.15cm, bar shift = -0.1cm,]
\addplot[color=black,fill=blue!60,]
coordinates {(1,4.39)(2,5.91)(3,8.37)(4,8.61)(5,10.46)};
\end{axis}

\begin{axis} [bar width = 0.15cm, bar shift = 0.1cm, hide axis,]
\addplot[color=black,fill=black!80,]
coordinates {(1,46.79)(2,48.77)(3,54.22)(4,53)(5,60.92)};
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary input trajectory size
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xlabel={Input size $|S| \cdot 10^3$},
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={5,10,20,30,40},
ybar,
ymin=0, ymax=90,
ytick={5,20,40,60,80},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.15cm, bar shift = -0.1cm,]
\addplot[color=black,fill=blue!60,]
coordinates {(1,4.39)(2,5.10)(3,5.80)(4,5.18)(5,5.79)};
\end{axis}

\begin{axis} [bar width = 0.15cm, bar shift = 0.1cm, hide axis,]
\addplot[color=black,fill=black!80,]
coordinates {(1,46.79)(2,46.04)(3,55.54)(4,55.88)(5,61.38)};
\end{axis}

\end{tikzpicture}
~
\begin{tikzpicture}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% vary dimension size
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pgfplotsset {
height=3.5cm,
width=4.6cm,
grid style=dashed,
xlabel={Dimension $d$ size},
xmode = normal,
xmin=0, xmax=6,
xtick=data,
xtick style={draw=none},
xticklabels={2,4,8,16,32},
ybar,
ymin=0, ymax=90,
ytick={5,20,40,60,80},
ymajorgrids=true,
yticklabels={,,},
}

\begin{axis} [bar width = 0.15cm, bar shift = -0.1cm,]
\addplot[color=black,fill=blue!60,]
coordinates {(1,4.39)(2,5.57)(3,6.25)(4,6.84)(5,6.76)};
\end{axis}

\begin{axis} [bar width = 0.15cm, bar shift = 0.1cm, hide axis,]
\addplot[color=black,fill=black!80,]
coordinates {(1,46.79)(2,46.97)(3,39.49)(4,40.6)(5,40.28)};
\end{axis}

\end{tikzpicture}

\caption{Our approach compared to Naive Scan, for exact $NN$ queries on Synthetic Data Sets.
}
\label{fig:NN_naive_compare}
\end{figure*}
  • 2
    Welcome to TeX-SE! This can be achieved with the pgfplots library groupplots. – marmot May 24 at 3:01
  • 1
    There is one more comment which I cannot refrain from making. Other folks can conceivably learn from a simple example consisting of a relatively small group of plots. They won't IMHO benefit from this very extensive code examples in which many keys get repeated 15 times. It is possible to answer this question but this means that someone presents a specialized solution just for this case. IMHO you should really put all repeating keys in styles, clean up, try out groupplots and if you encounter problems ask a question from which many could benefit. – marmot May 24 at 4:15
  • marmot - thanks for the direction. – user11162708 Jun 5 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.