在调整一些轴选项时,我发现了这种奇怪的行为。设置单位bar width
和bar shift auto
不设置单位时,条形图的位置不正确。日志中没有警告或错误消息。
这真的是一个错误吗,或者我错过了什么?
% arara: pdflatex
\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{times}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=7cm,height=7cm,bar shift auto=0pt]
\addplot[ybar, bar width=1, fill=blue] coordinates {(10,5) (15,10) (5,15) (24,20) (30,25)};
\addplot[ybar, bar width=1, fill=red] coordinates {(10,5) (15,10) (5,15) (24,20) (30,25)};
\node[anchor=north west] at (rel axis cs:0,1) {bar shift auto=0pt,bar width=1};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[width=7cm,height=7cm,bar shift auto=0]
\addplot[ybar, bar width=1, fill=blue] coordinates {(10,5) (15,10) (5,15) (24,20) (30,25)};
\addplot[ybar, bar width=1, fill=red] coordinates {(10,5) (15,10) (5,15) (24,20) (30,25)};
\node[anchor=north west] at (rel axis cs:0,1) {bar shift auto=0,bar width=1};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[width=7cm,height=7cm,bar shift auto=0pt]
\addplot[ybar, bar width=5pt, fill=blue] coordinates {(10,5) (15,10) (5,15) (24,20) (30,25)};
\addplot[ybar, bar width=5pt, fill=red] coordinates {(10,5) (15,10) (5,15) (24,20) (30,25)};
\node[anchor=north west] at (rel axis cs:0,1) {bar shift auto=0pt,bar width=5pt};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[width=7cm,height=7cm,bar shift auto=0]
\addplot[ybar, bar width=5pt, fill=blue] coordinates {(10,5) (15,10) (5,15) (24,20) (30,25)};
\addplot[ybar, bar width=5pt, fill=red] coordinates {(10,5) (15,10) (5,15) (24,20) (30,25)};
\node[anchor=north west] at (rel axis cs:0,1) {bar shift auto=0,bar width=5pt};
\end{axis}
\end{tikzpicture}%
\end{document}