# Histogram with Tikz

I am a newbie in TeX. And I need to use Tikz to make a copy of this histogram

Of course, I am able to make something similar. Unfortunately, I need a replica (90%) of it. Can anybody help me?

What I have:

\begin{tikzpicture}
\begin{axis}[
symbolic x coords={excellent, good, average, bad, awful},
ylabel = {probability},
xlabel = {Quality},
xtick=data]
(excellent,5)
(good,10)
(average,50)
(awful,15)
};
\end{axis}
\end{tikzpicture}


Perhaps something like this.

\documentclass[11pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}

\pgfplotsset{
xlabel near ticks,
ylabel near ticks
}

\begin{document}
\begin{tikzpicture}[font=\small]
\begin{axis}[
ybar,
bar width=20pt,
xlabel={Quality},
ylabel={Probability},
ymin=0,
ytick=\empty,
xtick=data,
axis x line=bottom,
axis y line=left,
enlarge x limits=0.2,
xticklabel style={anchor=base,yshift=-\baselineskip},
nodes near coords={\pgfmathprintnumber\pgfplotspointmeta\%}
]
(excellent,5)
(good,10)
(average,50)
(awful,15)
};
\end{axis}
\end{tikzpicture}
\end{document}


Here are a collection of settings that would fix tiny details. You can comment them out to see what they are doing. The arrow heads are from DIN conform arrowheads and hatching in TikZ?

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\makeatletter
\pgfarrowsdeclare{DIN}{DIN}
{
\pgfutil@tempdima=0.5pt%
\pgfarrowsleftextend{+-\pgfutil@tempdimb}
\pgfarrowsrightextend{+\pgfutil@tempdimb}
}
{
\pgfutil@tempdima=0.5pt%
\pgfsetdash{}{+0pt}
\pgfsetmiterjoin
\pgfpathlineto{\pgfqpoint{0.5\pgfutil@tempdima}{0\pgfutil@tempdima}}
\pgfpathclose
\pgfusepathqfillstroke
}
\pgfarrowsdeclarereversed{DIN reversed}{DIN reversed}{DIN}{DIN}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={excellent, good, average, bad, awful},
ylabel = {probability},
xlabel = {Quality},
ytick=\empty,ymin=0,
axis x line=bottom,
axis y line=left,
enlarge x limits=0.2,
axis line style={-DIN,ultra thin},
xtick=data,
nodes near coords={\pgfmathprintnumber\pgfplotspointmeta\%},
ylabel near ticks,
xticklabel style={anchor=base,yshift=-3mm},
xtick style={draw=none},
every axis x label/.style={at={(current axis.south east)},anchor=north west}
]
(excellent,5)
(good,10)
(average,50)

• @Matthias You can use the width and height keys. If you use only one of those keys, the other one is changed according to the aspect ratio of the box. You need to give both of them to change the aspect ratio, – percusse Jun 2 '15 at 8:08
• @Matthias Sure you can always use width = .8\textwidth and so on. – percusse Jun 2 '15 at 8:14