
如何在不影響繪圖本身的情況下調整使用 pgfplots/TikZ 製作的繪圖中軸的長度?
答案1
您在這裡有多種選擇:使用xmax
, ymax
, zmax
, xmin
, ymin
,zmin
鍵或鍵系列enlarge limits
, enlarge x limits
, enlarge y limits
, enlarge z limits
。一個小例子(該範例是 2D 的,但同樣的想法適用於 3D 繪圖):
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle]
\addplot+[no marks,domain=-2:2] {x};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
xmax=6,
ymax=6,
xmin=-6,
ymin=-6
]
\addplot+[no marks,domain=-2:2] {x};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
enlarge x limits=3,
enlarge y limits=3
]
\addplot+[no marks,domain=-2:2] {x};
\end{axis}
\end{tikzpicture}
\end{document}