The ybar interval
key is used to place the graph bars between the given coordinates. The next 5 coordinates define 4 intervals. This key works as expected and produces the following result.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis x line=bottom,axis y line=left,
ymin=0,ymax=8, xmin=20,xmax=50,
minor y tick num=1]
\addplot+ [ybar interval,fill=green] coordinates{(25,1) (30,4) (35,5) (40,2) (45,0)};
\end{axis}
\end{tikzpicture}
\end{document}
When the key is ybar stacked
the code produces 5 bars as expected.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis x line=bottom,axis y line=left,
ymin=0,ymax=8, xmin=20,xmax=50,
minor y tick num=1]
\addplot+ [ybar stacked,fill=green] coordinates{(25,1) (30,4) (35,5) (40,2) (45,0)};
\addplot+ [ybar stacked,pattern color=blue,draw=black,pattern=north east lines]coordinates{(25,1) (30,1) (35,2) (40,1) (45,2)};
\end{axis}
\end{tikzpicture}
\end{document}
When the key is ybar interval stacked
the code produces the following result which is not a stacking in the intervals.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis x line=bottom,axis y line=left,
ymin=0,ymax=8, xmin=20,xmax=50,
minor y tick num=1]
\addplot+ [ybar interval stacked,fill=green] coordinates{(25,1) (30,4) (35,5) (40,2) (45,0)};
\addplot+ [ybar interval stacked,pattern color=blue,draw=black,pattern=north east lines]coordinates{(25,1) (30,1) (35,2) (40,1) (45,2)};
\end{axis}
\end{tikzpicture}
\end{document}
- Is there a bug in pgfplots?
- Otherwise how does the
ybar interval stacked
key work?
I opened a ticket about it and Stefan Pinnow confirmed that it is a bug.
Translated with www.DeepL.com/Translator