I created this two plots using pgfplots package and put in the page using subfig package.

This is a part of the code I used to create it.
\begin{figure}[htp]
\centering
\begin{tikzpicture}[scale=0.8]
\begin{axis}[height=7cm,
x post scale=1.4,
xmin=0,xmax=6000,ymin=0,ymax=3500,
grid=both,
ylabel=Throughput (kbit/s),
/pgf/number format/.cd,
use comma,
1000 sep={},
legend pos = north west,
legend cell align=left,
name=main plot]
\addplot[smooth,thick,blue!70]
table[x=load,y=throughput]
{./immagini/throughput_blue.txt};
\addplot[smooth,thick,green!70]
table[x=load,y=throughput]
{./immagini/throughput_green.txt};
\legend{{\footnotesize Network Coding}, {\footnotesize No Network Coding}}
\end{axis}
\begin{axis}[height=3.8cm,
x post scale=1.4,
xmin=0,xmax=6000,ymin=0,ymax=2,
grid=both,
xlabel= Carico offerto totale (kbit/s),ylabel= Guadagno codifica,
/pgf/number format/.cd,
use comma,
1000 sep={},
at={(main plot.below south west)},yshift=-0.1cm,
anchor=north west]
\addplot[smooth,thick,red!70]
table[x=load,y=gain]
{./immagini/throughput_red.txt};
\end{axis}
\end{tikzpicture}
\caption{Confronto throughput per lo scenario \emph{mobile cloud}}
\label{fig:throughput_nc}
\end{figure}
The problem is, as you can see, the plots are not aligned vertically. I don't undestand the reason.where is the mistake?
axisenvironments in one and use TikZ alignments keys (anchor,at,yshift). So the second (lower) axis could have in the options:at={(<upper plot>.below south west)}, anchor=north west, yshift=-<additional padding>; where<upper plot>is the name of the upper plot (option:name=<upper plot>). Check section 4.18 and especially subsection 4.18.4 of the PGFPlots manual (“Alignment Options and Bounding Box Control”/“Horizontal Alignment”). – Qrrbrbirlbel Jan 05 '13 at 08:57groupplotslibrary and itsgroupplotenvironment (section 5.5 “Grouping plots”). If you intentionally want to have totikzpictures (two captions, two floats, pabe-break between both plots (which I wouldn’t recommend as both plots share their x axis)) you’ll have to use something that @Vivi had in mind (empty nodes,minimum widths,\hphantom, …). Anyhow, without the actualaxisenvironments there is not much to help you with. – Qrrbrbirlbel Jan 05 '13 at 09:04\begin{tikzpicture}[trim axis left, trim axis right], compare the pgfplots manual, section alignment. – Christian Feuersänger Jan 05 '13 at 10:33%after every{or}which ends a line to avoid a spurious space there. See What is the use of percent signs (%) at the end of lines? for the details. Such things can influence the horizontal alignment. – Martin Scharrer Jan 05 '13 at 11:02/pgf/number format/.cdthat changes how PGF keys work. Moveyshift(and everything else that does not belong to the/pgf/number format/tree) in front of that. PS: Use for example@Qrrbrbirlbelin your comment to address a specific user (as I did in this comment) so that they get a notification. – Qrrbrbirlbel Jan 05 '13 at 13:41