1

I am facing an alignment problem with a sequence of tree plots, one under the other, that I do not have any clue how to fix it. The problem is shown in the figure bellow. As it shows, the graphs are not aligned horizontally or they are not of the same size. The plots are made via pgfplots and subfig packges. The code used to generate them are in the end of this text. Any help is welcome!!!

PS: I am not sure if the problem is really the non-alignment of the figures or if it is the size of the figure that may be different.

enter image description here

\begin{figure}[!htb]
\subfloat[Evolução das posições $x$ e $y$]{
\begin{tikzpicture}
\begin{axis}[
                title={Evolução das posições $x$ e $y$ para diferentes condições iniciais e velocidade de $2$m/s},
                xlabel={Tempo [s]}, ylabel={Erro [m]},
                axis equal,
                grid=major,
                xmin=0, xmax=20,
            ]
\addplot[only marks, mark size=1.0pt, color=blue,] 
         table [x={x}, y={y}, col sep=comma]{chapters/cap3/csv/PIV_0_2_0_20_state.csv};

\addplot[only marks, mark size=1.0pt, color=red,] 
         table [x={x}, y={y}, col sep=comma]{chapters/cap3/csv/PIV_0_2_45_20_state.csv};

\addplot[only marks, mark size=1.0pt, color=green,] 
         table [x={x}, y={y}, col sep=comma]{chapters/cap3/csv/PIV_0_2_90_20_state.csv};
\end{axis}
\end{tikzpicture}
}\label{fig:piv_0_2_20_state}

\subfloat[Evolução do erro previsto $\delta_p$]{
\begin{tikzpicture}
\begin{axis}[
                title={Evolução do erro previsto $\delta_p$ para diferentes condições iniciais e velocidade de $2$m/s},
                xlabel={Tempo [s]}, ylabel={Erro [m]},
                grid=major,
                xmin=0, xmax=20,
            ]
\addplot[only marks, mark size=1.0pt, color=blue,] 
         table [x={time}, y={error}, col sep=comma]{chapters/cap3/csv/PIV_0_2_0_20.csv};

\addplot[only marks, mark size=1.0pt, color=red,] 
         table [x={time}, y={error}, col sep=comma]{chapters/cap3/csv/PIV_0_2_45_20.csv};

\addplot[only marks, mark size=1.0pt, color=green,] 
         table [x={time}, y={error}, col sep=comma]{chapters/cap3/csv/PIV_0_2_90_20.csv};
\end{axis}
\end{tikzpicture}
}\label{fig:piv_0_2_20_error}

\subfloat[Evolução das posições $x$ e $y$]{
\begin{tikzpicture}
\begin{axis}[
                title={Evolução do sinal de controle para diferêntes condições iniciais e velocidade de $2$m/s},
                xlabel={Tempo [s]}, ylabel={Sinal de controle [rad]},
                grid=major,
                xmin=0, xmax=20,
            ]
\addplot[only marks, mark size=1.0pt, color=blue,] 
         table [x={time}, y={sign}, col sep=comma]{chapters/cap3/csv/PIV_0_2_0_20.csv};

\addplot[only marks, mark size=1.0pt, color=red,] 
         table [x={time}, y={sign}, col sep=comma]{chapters/cap3/csv/PIV_0_2_45_20.csv};

\addplot[only marks, mark size=1.0pt, color=green,] 
         table [x={time}, y={sign}, col sep=comma]{chapters/cap3/csv/PIV_0_2_90_20.csv};
\end{axis}
\end{tikzpicture}
}\label{fig:piv_0_2_20_sign}
\caption{Evolução do sinal de controle ao longo do tempo. Em azul, simulação inicianda do estado $(0,1,0^\circ)$ e velocidade de $2$m/s; em vermelho, simulação iniciada do estado $(0,1,45^\circ)$ e velocidade de $2$m/s; em verde simulação iniciada do estado $(0,1,90^\circ)$ e velocidade de $2$m/s.}
\end{figure}
  • Welcome to TeX. SE. Please always instead of code snippet provide complete small document beginning with \documentclass{...} and ending with \end{document}. In preamble let be loaded only those packages which are related to the your problem. Also in your case, make all data available to us (we haven't your tabulated data). – Zarko Feb 10 '17 at 13:47
3

Your images haven't equal width. Difference -- actullay they are very small ...)arise from different width of ytick labels. the last image have the widest -- caused with -0.5. Differences you can compensate with enlarge graphs width that their title don't spill-out of graphs borders (or use multi line title) and positioning of y axis label relative to left border of graphs:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\usepackage{subfig}
\usepackage[utf8]{inputenc}

\begin{document}
    \begin{figure}[ht]
\pgfplotsset{%axis equal,
             grid=major,
             xmin=0, xmax=22,
             width=15cm, height=5cm,
             every axis y label/.style={at={(-0.06,0.5)},
                rotate=90, anchor=south}
             }

\subfloat[Evolução das posições $x$ e $y$   \label{fig:piv_0_2_20_state}]{
\begin{tikzpicture}
\begin{axis}[
           title={Evolução das posições $x$ e $y$ para diferentes condições iniciais e velocidade de $2$m/s},
           xlabel={Tempo [s]}, ylabel={Erro [m]},
            ]
\addplot[color=blue]  coordinates {(0,0) (20,1)};
\addplot[color=red]   coordinates {(0,2) (20,1)};
\addplot[color=green] coordinates {(0,4) (20,1)};
\end{axis}
\end{tikzpicture}
}

\subfloat[Evolução do erro previsto $\delta_p$  \label{fig:piv_0_2_20_error}]{
\begin{tikzpicture}
\begin{axis}[
        title={Evolução do erro previsto $\delta_p$ para diferentes condições iniciais e velocidade de $2$m/s},
        xlabel={Tempo [s]}, ylabel={Erro [m]},
            ]
\addplot[color=blue]  coordinates {(0,0)  (20,0)};
\addplot[color=red]   coordinates {(0,-1) (20,0)};;
\addplot[color=green] coordinates {(0,-2) (20,0)};;
\end{axis}
\end{tikzpicture}
}

\subfloat[Evolução das posições $x$ e $y$   \label{fig:piv_0_2_20_sign}]{
\begin{tikzpicture}
\begin{axis}[
        title={Evolução do sinal de controle para diferêntes condições iniciais e velocidade de $2$m/s},
        xlabel={Tempo [s]}, ylabel={Sinal de controle [rad]},
            ]
\addplot[color=blue]  coordinates {(0,  0) (20,0)};
\addplot[color=red]   coordinates {(0, .5) (20,0)};;
\addplot[color=green] coordinates {(0,-.5) (20,0)};;
\end{axis}
\end{tikzpicture}
}
\caption{Evolução do sinal de controle ao longo do tempo. Em azul, simulação inicianda do estado $(0,1,0^\circ)$ e velocidade de $2$m/s; em vermelho, simulação iniciada do estado $(0,1,45^\circ)$ e velocidade de $2$m/s; em verde simulação iniciada do estado $(0,1,90^\circ)$ e velocidade de $2$m/s.}
    \end{figure}
\end{document}

enter image description here

| improve this answer | |
  • What exactly the command every axis y label/.style={at={(-0.06,0.5)} does? – Randerson Feb 10 '17 at 14:28
  • determine y label style: it is placed 6% of table width left from graph and at 50% of graph height, rotate and anchor is on the south (observing before rotation). with this is determined label position regarding to graph and not to ytick labels. – Zarko Feb 10 '17 at 14:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.