我想讓我的垂直軸高於最大值 1.0,低於最小值 1.0(隱式)。雖然這樣enlarge y limits
可以完成工作,但事實並非如此。我不確定這個函數實際上是如何運作的,以及它是否是解決我的問題的正確方法。
對於我的 MWE,垂直範圍在 2 到 7 之間,因此我希望將垂直軸設置在 1 到 8 之間。所以 ymin=1
和ymax=8
不是答案。
這是我的 MWE
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{csvsimple}
\usepackage{filecontents}
\begin{filecontents*}{data.csv}
x,value
0, 3
5, 6
14, 7
31, 2
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
\centering
\begin{axis}[
enlarge y limits = 1
]
\addplot table [x=x, y=value, col sep=comma] {data.csv};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
預設情況下,正如您在手冊中看到的那樣(2.xx版本的手冊第4.14章,第273頁),您有一個相對放大:
/pgfplots/enlarge y limits=auto|true|false|upper|lower| val |value=val |abs value= val | abs= val |rel= val (initially auto)
所以你enlarge y limits = 1
將 y 軸的限制擴大了 100%;也許您可以透過放大 10%
enlarge y limits = 0.1
或類似的值來獲得您正在尋找的東西。
要將其放大固定值,您應該這樣做
enlarge y limits={abs=1}
獲得: