答案1
您可以使用偏移量移动标签
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\pgfplotstableread{
a b c
1 10 20
2 45 130
3 30 60
}\mytable
\begin{document}
\begin{tikzpicture}
\begin{axis}[ybar,xtick=data,enlarge y limits={upper=5},ymin=0,
yticklabel={\pgfmathparse{\tick-120}\pgfmathprintnumber{\pgfmathresult}}]
\addplot table[x=a,y=b] {\mytable};
\addplot table[x=a,y=c] {\mytable};
\end{axis}
\end{tikzpicture}
\end{document}
答案2
您可以在属性中使用ymax
和。请考虑以下示例。不设置参数(注释行):ymin
axis
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar=15,
%ymin=0,
%ymax=120,
symbolic x coords={a small bar,a medium bar,a large bar},
xtick=data]
\addplot[ybar,fill=blue] coordinates {
(a small bar,42)
(a medium bar,50)
(a large bar,80)
};
\end{axis}
\end{tikzpicture}
\end{document}
取消注释这些行,你将获得不同的 Y 轴范围: