# pgfplots - lack of one bar

I want to make a chart with nine bars. As you can see they are in the code (0-8). Unfortunately it's making only eight bars.

\documentclass[12pt]{report}
\usepackage{polski}
\usepackage{pgfplots,tikz}
\pagestyle{empty}
\pgfplotsset{width=14cm,compat=1.3}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x tick label style={
/pgf/number format/1000 sep=},
ylabel=Prawdopodobieństwo,
enlargelimits=0.02,
legend style={at={(0.5,-0.15)},
anchor=north,legend=-1},
ybar interval=0.8,
]
coordinates{
(0,0.00390625)
(1,0.03125)
(2,0.109375)
(3,0.21875)
(4,0.273438)
(5,0.21875)
(6,0.109375)
(7,0.03125)
(8,0.00390625)
};
coordinates{
(0,0.00405)
(1,0.03143)
(2,0.10847)
(3,0.21984)
(4,0.2723)
(5,0.2166)
(6,0.11272)
(7,0.03062)
(8,0.00397)
};
coordinates{
(0,0.00261035)
(1,0.0237304)
(2,0.107973)
(3,0.221879)
(4,0.270052)
(5,0.22449)
(6,0.108685)
(7,0.0363075)
(8,0.00427148)
};
\end{axis}
\end{tikzpicture}
\end{document}

-

This works for me if I change ybar interval=0.8 to just ybar and remove enlargelimits=0.02. I guess you may need to adjust the settings a little more carefully starting from a working plot and going toward what you want.

-

If you want to use the ybar interval style, you need to supply an extra "dummy datapoint" to each plot. This is necessary because the interval style is used for plotting bars over ranges, not at points, so in order to calculate the width of the last range, you need to supply an upper limit.

\documentclass[12pt]{report}
\usepackage{polski}
\usepackage{pgfplots,tikz}
\pagestyle{empty}
\pgfplotsset{width=14cm,compat=1.3}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ybar interval,
x tick label style={
/pgf/number format/1000 sep=},
ylabel=Prawdopodobieństwo,
enlargelimits=0.02,
legend style={at={(0.5,-0.15)},
anchor=north,legend=-1},
]
coordinates{
(0,0.00390625)
(1,0.03125)
(2,0.109375)
(3,0.21875)
(4,0.273438)
(5,0.21875)
(6,0.109375)
(7,0.03125)
(8,0.00390625)
(9,0)
};
coordinates{
(0,0.00405)
(1,0.03143)
(2,0.10847)
(3,0.21984)
(4,0.2723)
(5,0.2166)
(6,0.11272)
(7,0.03062)
(8,0.00397)
(9,0)
};
coordinates{
(0,0.00261035)
(1,0.0237304)
(2,0.107973)
(3,0.221879)
(4,0.270052)
(5,0.22449)
(6,0.108685)
(7,0.0363075)
(8,0.00427148)
(9,0)
};

Alternatively, you can just use the ybar style. In that case, you should use enlarge y limits=0.02 instead of enlargelimits=0.02 to make sure that no bars are cut off at the sides. Notice especially the difference in the tick marks and the vertical dividing lines in the resulting plot.