# Remove spaces between bars

I'm a little bit confused why latex messes an easy drawing up. More precisely, I use the following code:


\begin{tikzpicture}
\begin{axis}[title  = {Tex example},
xbar,
ytick             = {Part1, Part2, Part3, Part4, Part5, Part6, Part7},
symbolic y coords = {Part1, Part2, Part3, Part4, Part5, Part6, Part7},
nodes near coords,
]
\end{axis}
\end{tikzpicture}


But this generates the following picture: How do I get the y labels aligned to the according bars? (And may reduce the distance between the bars in general)?

LaTeX or in the case PGFPlots, does not mess anything up. The normal behaviour is to shift the bars, so that multiple plots does not lie on top of each other. Your data does not really need multiple \addplot, but if the bars are really considered separate plot that can have separate legend entries, you can do it like this:

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title={Tex example},
xbar,
symbolic y coords={Part1, Part2, Part3, Part4, Part5, Part6, Part7},
ytick distance=1,
nodes near coords,
bar shift=0pt,
bar width=18pt,
enlarge x limits={value=0.2, upper},
]

\addplot coordinates {(40.2,Part1) (30.9,Part2) (10.2,Part3) (10.1,Part4) (4.3,Part5) (2.5,Part6) (1.0,Part7)};