pgf-tikz / pgfplots

pgfplots - A TeX package to draw normal and/or logarithmic plots directly in TeX in two and three dimensions with a user-friendly interface and pgfplotstable - a TeX package to round and format numerical tables. Examples in manuals and/or on web site.
http://pgfplots.sourceforge.net/
200 stars 35 forks source link

bug with the `ybar interval stacked` key #218

Open pgf-tikz-bot opened 5 years ago

pgf-tikz-bot commented 5 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/218/ Author: andre-c Timestamp: 2019-02-05 06:04:26.661000

When the key is ybar interval stacked the code produces the following result which is not a stacking in the intervals. screenshot

\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}
pgf-tikz-bot commented 5 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/218/#ab8f Author: mo-gul Timestamp: 2019-02-05 18:19:46.150000

https://sourceforge.net/p/pgfplots/bugs/_discuss/thread/e0b5f1f18c/ab8f/attachment/P.PNG I can confirm this. This also happens, when ybar stacked interval is moved to the axis options (see the attached screenshot).

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \usetikzlibrary{patterns}
    \pgfplotsset{
        compat=1.16,
        my axis style/.style={
            xmin=20,
            xmax=50,
            ymin=0,
            ymax=8,
            axis x line=bottom,
            axis y line=left,
            minor y tick num=1,
        },
    }
    \newcommand*\AddPlots{
        \addplot+ [
            pattern color=green,
            draw=black,
            pattern=north west lines,
        ] coordinates {(25,1) (30,4) (35,5) (40,2) (45,0)};
        \addplot+ [
            pattern color=blue,
            draw=black,
            pattern=north east lines,
        ] coordinates {(25,1) (30,1) (35,2) (40,1) (45,2)};
    }
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        my axis style,
        ybar stacked,
    ]
        \AddPlots
    \end{axis}
\end{tikzpicture}
\begin{tikzpicture}
    \begin{axis}[
        my axis style,
        ybar interval stacked,
    ]
        \AddPlots
    \end{axis}
\end{tikzpicture}
\end{document}