我想水平对齐我的两个图表,以便 y 轴对齐。问题是其中一个 y 轴有两位数,而另一个 y 轴有一位数作为单位。
\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}
答案1
一种可能性是trim axis left
对两种tikzpicture
环境都使用选项:
\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}