This is my histogram:
\documentclass{article}
\usepackage{pgfplots,tikz}
\pgfplotsset{width=7cm,compat=1.13}
\usepgfplotslibrary{statistics}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
height=8cm,width=12cm,
ybar interval,
ymin=0, ymax=16,
xmin=0,xmax=100,
grid=both,
minor y tick num = 1,
yminorgrids=true,
]
\addplot+[ybar interval, mark=no] plot
coordinates {(0,13)(10,8)(20,15)(30,7)(40,2)(50,3)(60,1)(70,0)(80,1)(90,0)(100,0)};
\end{axis}
\end{tikzpicture}
\end{document}
- I would like the x values to move from the centre of the bar to the left of the bar. (Keeping the first bar stuck to the y-axis.)
- I would like the last value of x=100 to also appear at the end of the x axis.
- And I'd like the y-axis ticks outside black border line instead of inside.
Best Answer
You almost had it. The main issue was the
ybar interval
in the axis options which cause thexticks
to be centered under the bar. For the rest, have a look at the comments in the code.