Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to put to put 2 graphs aligned, here is my MWE:

\documentclass[11pt, letterpaper]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[right=1.5cm,left=1.5cm,top=2.5cm,bottom=2.0cm,headsep=1.2cm,footskip=1.5cm]{geometry} % Márgenes





\begin{document}


\begin{figure}[!htbp]
\begin{tabular}{c c }
\begin{subfigure}{0.45\textwidth}
\begin{tikzpicture}
\pgfplotsset{
x coord trafo/.code={\pgfmathparse{#1^0.5}\pgfmathresult},
yticklabel style={/pgf/number format/fixed},
x coord inv trafo/.code={\pgfmathparse{#1^2}\pgfmathresult}}
\begin{axis}[
yticklabel style={/pgf/number format/fixed},
height=7.5cm,
width=7.5cm,
yticklabel style={/pgf/number format/fixed},
xlabel=$t $ (min),
ylabel= {s(t) = $L_{0}-L$ (mm)},
%grid=major,
y dir=reverse,
]
\addlegendentry[font=\tiny]{0,1 kg/cm$^{2}$}
\addplot[black, small,mark=*,mark size=1pt] coordinates {
(0.000001, 0.000)
(0.100, 0.032)
(0.250, 0.032)
(0.500, 0.032)
(1.000, 0.034)
(2.250, 0.034)
(4.000, 0.036)
(6.250, 0.036)
(9.000, 0.037)
(12.250, 0.039)
(16.000, 0.039)
(20.250, 0.040)
(25.000, 0.040)
(40.000, 0.041)
(60.000, 0.043)
(90.000, 0.043)
(120.000, 0.045)
(180.000, 0.048)
(480.000, 0.051)
(1440.000, 0.051)
};
\end{axis}
\end{tikzpicture}
\caption{0.1 kg/cm$^{2}$}
\label{fig:01}
\end{subfigure}
 & 
\begin{subfigure}{0.45\textwidth}
\begin{tikzpicture}
\pgfplotsset{
x coord trafo/.code={\pgfmathparse{#1^0.5}\pgfmathresult},
x coord inv trafo/.code={\pgfmathparse{#1^2}\pgfmathresult}}
\begin{axis}[
height=7.5cm,
width=7.5cm,
xlabel=$t$ (min),
ylabel= {s(t) = $L_{0}-L$ (mm)},
%grid=major,
y dir=reverse,
]
\addlegendentry[font=\tiny]{0,25 kg/cm$^{2}$}
\addplot[red, small,mark=*,mark size=1pt] coordinates {
(0.000001, 0.000)
(0.100, 0.129)
(0.250, 0.159)
(0.500, 0.177)
(1.000, 0.189)
(2.250, 0.204)
(4.000, 0.209)
(6.250, 0.214)
(9.000, 0.219)
(12.250, 0.221)
(16.000, 0.224)
(20.250, 0.227)
(25.000, 0.229)
(40.000, 0.233)
(60.000, 0.238)
(90.000, 0.241)
(120.000, 0.245)
(180.000, 0.249)
(480.000, 0.259)
(1440.000, 0.261)
};
\end{axis}
\end{tikzpicture}
\caption{0.2 kg/cm$^{2}$}
\label{fig:02}
\end{subfigure}
\\
\end{tabular}
\end{figure}




\end{document}

but the output is not aligned. I suspected this is because the left hand graph has the y axis format different (I tried to change it and failed), but then I realized that this is not the case either, because the top of the right hand graph is not aligned with the top of the $10^{-2}$.

Is there a way I can fix this? Do you know other method for aligning them other than tabular?

share|improve this question
    
Unrelated to the alignment problem: Wouldn't a log scale for the x axis (xmode=log instead of the x coord trafo) make the graph clearer? –  Jake Jun 20 '13 at 18:57
    
@Jake, for determining the coefficient of consolidation of a soil there are several methods, Taylor's method uses the square root of time for doing that, that's why I need to use that strange scale. –  Francisco Jun 20 '13 at 19:12
    
Ah, okay! Thanks for the explanation –  Jake Jun 20 '13 at 19:15
add comment

2 Answers

up vote 3 down vote accepted

Why not using the optional argument for subfigure? In the following example I chose b (for alignment at the bottom):

\documentclass[11pt, letterpaper]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[right=1.5cm,left=1.5cm,top=2.5cm,bottom=2.0cm,headsep=1.2cm,footskip=1.5cm]{geometry} % Márgenes

\begin{document}

\begin{figure}
\begin{subfigure}[b]{0.45\textwidth}
\centering
\begin{tikzpicture}
\pgfplotsset{
x coord trafo/.code={\pgfmathparse{#1^0.5}\pgfmathresult},
yticklabel style={/pgf/number format/fixed},
x coord inv trafo/.code={\pgfmathparse{#1^2}\pgfmathresult}}
\begin{axis}[
yticklabel style={/pgf/number format/fixed},
height=7.5cm,
width=7.5cm,
yticklabel style={/pgf/number format/fixed},
xlabel=$t $ (min),
ylabel= {s(t) = $L_{0}-L$ (mm)},
%grid=major,
y dir=reverse,
]
\addlegendentry[font=\tiny]{0,1 kg/cm$^{2}$}
\addplot[black, small,mark=*,mark size=1pt] coordinates {
(0.000001, 0.000)
(0.100, 0.032)
(0.250, 0.032)
(0.500, 0.032)
(1.000, 0.034)
(2.250, 0.034)
(4.000, 0.036)
(6.250, 0.036)
(9.000, 0.037)
(12.250, 0.039)
(16.000, 0.039)
(20.250, 0.040)
(25.000, 0.040)
(40.000, 0.041)
(60.000, 0.043)
(90.000, 0.043)
(120.000, 0.045)
(180.000, 0.048)
(480.000, 0.051)
(1440.000, 0.051)
};
\end{axis}
\end{tikzpicture}
\caption{0.1 kg/cm$^{2}$}
\label{fig:01}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.45\textwidth}
\centering
\begin{tikzpicture}
\pgfplotsset{
x coord trafo/.code={\pgfmathparse{#1^0.5}\pgfmathresult},
x coord inv trafo/.code={\pgfmathparse{#1^2}\pgfmathresult}}
\begin{axis}[
height=7.5cm,
width=7.5cm,
xlabel=$t$ (min),
ylabel= {s(t) = $L_{0}-L$ (mm)},
%grid=major,
y dir=reverse,
]
\addlegendentry[font=\tiny]{0,25 kg/cm$^{2}$}
\addplot[red, small,mark=*,mark size=1pt] coordinates {
(0.000001, 0.000)
(0.100, 0.129)
(0.250, 0.159)
(0.500, 0.177)
(1.000, 0.189)
(2.250, 0.204)
(4.000, 0.209)
(6.250, 0.214)
(9.000, 0.219)
(12.250, 0.221)
(16.000, 0.224)
(20.250, 0.227)
(25.000, 0.229)
(40.000, 0.233)
(60.000, 0.238)
(90.000, 0.241)
(120.000, 0.245)
(180.000, 0.249)
(480.000, 0.259)
(1440.000, 0.261)
};
\end{axis}
\end{tikzpicture}
\caption{0.2 kg/cm$^{2}$}
\label{fig:02}
\end{subfigure}
\end{figure}

\end{document}

enter image description here

share|improve this answer
    
I should have thought that. Gracias! –  Francisco Jun 20 '13 at 19:13
    
@Francisco ¡De nada! –  Gonzalo Medina Jun 20 '13 at 19:20
add comment

In this solution, the first thing I did to make it easier to see the solution was to put your two images in separate files and then \input them to the figure. In this case, I use a \shortstack so that the figures stack from the baseline.

\documentclass[11pt, letterpaper]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{caption}
\usepackage[right=1.5cm,left=1.5cm,top=2.5cm,bottom=2.0cm,headsep=1.2cm,footskip=1.5cm]{geometry} % Márgenes

\begin{document}

\begin{figure}[!htbp]
\small
\shortstack{\input{pica}\\(a) 0.1 kg/cm$^{2}$}
~~~~~
\shortstack{\input{picb}\\(b) 0.2 kg/cm$^{2}$}
\normalsize
\caption{This is my figure}
\end{figure}

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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