TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

enter image description here

This is a part of the code I used to create it.

                         x post scale=1.4,
                         ylabel=Throughput (kbit/s),
                         /pgf/number format/.cd,
                         use comma,
                         1000 sep={},
                         legend pos = north west,
                         legend cell align=left,
                         name=main plot]
                \legend{{\footnotesize Network Coding}, {\footnotesize No Network Coding}}

                         x post scale=1.4,
                         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]
\caption{Confronto throughput per lo scenario \emph{mobile cloud}}

The problem is, as you can see, the plots are not aligned vertically. I don't undestand the reason.where is the mistake?

share|improve this question

closed as too localized by Kurt, lockstep, zeroth, Werner, percusse Feb 16 '13 at 2:55

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

The problem is due to the fact that the labels of the y axis (the numbers) are longer in the first subplot. With pgfplots this is easily solvable with a global setting (one of my questions is about that), but in your case you could solve this by including an invisible node on the left of your figure to shift it to the right. For a more elegant solution it would help to see a stripped down version of your code. – Vivi Jan 5 '13 at 3:17
As you only use one caption (but two subfloats?) you can simply include both axis environments 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 5 '13 at 8:57
You may also interested in the groupplots library and its groupplot environment (section 5.5 “Grouping plots”). If you intentionally want to have to tikzpictures (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 actual axis environments there is not much to help you with. – Qrrbrbirlbel Jan 5 '13 at 9:04
What, precisely, do you want to center? If you want the left/right axis lines to be centered horizontally, you can exclude any descriptions outside of this range from the bounding box. This can be achieved using \begin{tikzpicture}[trim axis left, trim axis right], compare the pgfplots manual, section alignment. – Christian Feuersänger Jan 5 '13 at 10:33
You might want to add a % 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 5 '13 at 11:02