[Tex/LaTex] Add text within tikz rectangle node

tikz-pgf

I am trying to add a centrally aligned text in the middle of each horizontal bar, but can't seem to figure out how. How can I best do that?

 \documentclass{article}

    \usepackage{xcolor}
    \usepackage{tikz}

    \definecolor{high}{rgb}{0.89, 0.26, 0.2}
    \definecolor{med}{rgb}{1.0, 0.65, 0.0}
    \definecolor{low}{rgb}{0.98, 0.93, 0.36}

    \begin{document}
    \begin{figure}
    \centering
    \begin{tikzpicture}
    \foreach  \l/\x/\c[count=\y] in {A/6/high, B/4/med, C/2/low}
    {\node[left] at (0,\y) {\l};
    \draw[fill=\c] (0,\y-.4) rectangle (\x,\y+.4);}
    \end{tikzpicture}
    \end{figure}
    \end{document}

enter image description here

Best Answer

You just have to add a node at \x/2:

enter image description here

\documentclass{article}

% \usepackage{xcolor}% TikZ already loads xcolor
\usepackage{tikz}

\definecolor{high}{rgb}{0.89, 0.26, 0.2}
\definecolor{med}{rgb}{1.0, 0.65, 0.0}
\definecolor{low}{rgb}{0.98, 0.93, 0.36}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\foreach  \l/\x/\c/\stuff[count=\y] in {%
  A/6/high/text for everyone!,
  B/4/med/more text,
  C/2/low/some text}
{%
  \node [left] at (0,\y) {\l};
  \draw [fill=\c] (0,\y-.4) rectangle (\x,\y+.4);
  \node [anchor=center] at (\x/2,\y) {\stuff};
}
\end{tikzpicture}
\end{figure}
\end{document}