3

I want to horizontally align my two graphs, so that the y-axes are aligned. The problem is that the one y-axis has double digits and the other has single digits as the units.

\documentclass[12pt]{article} 
\usepackage{tikz, color}
\usepackage{pgfplots}

\pgfplotsset{compat=1.12, width=12cm}

\begin{document} 

\begin{tikzpicture}
\begin{axis}[axis lines = left, xmin=0, ymin=0]
\addplot [domain=0:80]
    {0.001*x^3-0.09*x^2+2.95*x}
    ;
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[axis lines = left, xmin=0, ymin=0]
\addplot [domain=0:80]
    {0.001*x^2-0.09*x+2.95}
    ;
\addplot [domain=0:80]
    {0.003*x^2-0.18*x+2.95}
    ;
\end{axis}
\end{tikzpicture}

\end{document}
  • $\ \, $ does the trick, but I want a proper method. – ahorn Apr 13 '16 at 22:43
  • You could also have a look at the groupplots library of pgfplots. – Torbjørn T. Sep 29 '16 at 13:14
1

One possibility is using option trim axis left for both tikzpicture environments:

enter image description here

\documentclass[12pt]{article} 
\usepackage{pgfplots}
\pgfplotsset{compat=1.12, width=12cm}
\usepackage{showframe}
\begin{document} 
\begin{center}
\begin{tikzpicture}[trim axis left]
\begin{axis}[axis lines = left, xmin=0, ymin=0]
\addplot [domain=0:80]
    {0.001*x^3-0.09*x^2+2.95*x}
    ;
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}[trim axis left]
\begin{axis}[axis lines = left, xmin=0, ymin=0]
\addplot [domain=0:80]
    {0.001*x^2-0.09*x+2.95}
    ;
\addplot [domain=0:80]
    {0.003*x^2-0.18*x+2.95}
    ;
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

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.