# Vertical space in tikzpicture

I would like to know how to space properly the bar produced by this code for them not to overlay the text :

\documentclass[tikz]{standalone}
\begin{document}
\newcommand\programming[1]{
\renewcommand{\programming}{
\begin{tikzpicture}[scale = 0.55, xshift = 1cm]
\foreach [count=\i] \x/\y in {#1} {
\node[above right,minimum height = 0.25cm] at (0,\i+0.35) {\x};
\draw[fill=lightgray,lightgray] (0,\i) rectangle (6,\i+0.4);
\draw[fill=white,materialblue](0,\i) rectangle (\y,\i+0.4);
}
\end{tikzpicture}
}
}
\programming{{C $\textbullet$ C++ $\textbullet$ R / 3}, {Java $\textbullet$ SQL $\textbullet$ \large \LaTeX / 3.5}, {HTML5 $\textbullet$ JS $\textbullet$ Python / 5}}
\end{document}


producing :

• make from your code snippets one small, but complete and compilable document! – Zarko Sep 3 '17 at 15:14
• After 6 questions you probably know how to provide a MWE (tex.meta.stackexchange.com/questions/228). Considering you rate your LaTeX skills 3.5 out of 5 :). – Dr. Manuel Kuehner Sep 3 '17 at 15:15
• @Dr.ManuelKuehner Well said ! Modifying it right away ;) – Le Duc Banal Sep 3 '17 at 15:24
• Did you test your MWE? I can't produce an output (pdflatex). – Dr. Manuel Kuehner Sep 3 '17 at 15:52

scale doesn't change font size. consequently when you with scale=... you reduce rectangle size and distance between them rectangles overlap text which keep used font size. to overcome this problem, you have more possibilities, for example:

• not use scale and draw images in size which you like to have
• use xscale which scale only width of images

in the firs case you can obtain something like this:

and in the second for example at xscale=0.55 like this:

slightly simplified mwe is:

\documentclass[tikz, margin=3mm]{standalone}
\colorlet{materialblue}{blue!40}
\colorlet{lightgray}{black!15}
\newcommand\programming[1]{
\begin{tikzpicture}[xscale=0.55]
\foreach \i/\j [count=\k from 0] in {#1} {
\node[above right,
inner sep=2pt] at (0,\k) {\i};
\fill[lightgray]        (0,\k) rectangle ( 6,\k-0.4);
\fill[materialblue]     (0,\k) rectangle (\j,\k-0.4);
}
\end{tikzpicture}
}

\begin{document}
\programming{{C $\textbullet$ C++ $\textbullet$ R / 3},
{Java $\textbullet$ SQL $\textbullet$ \large \LaTeX / 3.5},
{HTML5 $\textbullet$ JS $\textbullet$ Python / 5}}
\end{document}


Just remove scale=0.55, and your diagram looks fine.

\documentclass[tikz,border=5mm]{standalone}
\colorlet{materialblue}{blue!40}
\colorlet{lightgray}{black!15}
\newcommand\programming[1]{
\begin{tikzpicture}%[scale = 0.55]
\foreach [count=\j] \x/\y in {#1} {
\node[above right,minimum height = 0.25cm] at (0,\j+0.35) {\x};
\draw[fill=lightgray,lightgray] (0,\j) rectangle (6,\j+0.4);
\draw[fill=white,materialblue](0,\j) rectangle (\y,\j+0.4);
}
\end{tikzpicture}
}

\begin{document}
\programming{{C $\textbullet$ C++ $\textbullet$ R / 3}, {Java $\textbullet$ SQL $\textbullet$ \large \LaTeX / 3.5}, {HTML5 $\textbullet$ JS $\textbullet$ Python / 5}}

\end{document}


# Original answer, keeping scale=0.55

You need of course to have y-levels spaced by more than 1, which you can do for example by multiplying \i with a number larger than 1.

\documentclass[tikz]{standalone}
\colorlet{materialblue}{blue!40}
\colorlet{lightgray}{black!15}
\newcommand\programming[1]{
\begin{tikzpicture}[scale = 0.55]
\foreach [count=\i,evaluate=\i as \j using \i*1.5] \x/\y in {#1} {
\node[above right,minimum height = 0.25cm] at (0,\j+0.35) {\x};
\draw[fill=lightgray,lightgray] (0,\j) rectangle (6,\j+0.4);
\draw[fill=white,materialblue](0,\j) rectangle (\y,\j+0.4);
}
\end{tikzpicture}
}

\begin{document}
\programming{{C $\textbullet$ C++ $\textbullet$ R / 3}, {Java $\textbullet$ SQL $\textbullet$ \large \LaTeX / 3.5}, {HTML5 $\textbullet$ JS $\textbullet$ Python / 5}}

\end{document}

• +1 What is the natural height of i? – Dr. Manuel Kuehner Sep 3 '17 at 16:46
• @Dr.ManuelKuehner Well, \i is just a counter, so 1, 2, 3, etc. The default unit vector is 1cm, but scale=0.55 means it's 5.5mm here. (Which made me think of something, so thanks. Edit upcoming.) – Torbjørn T. Sep 3 '17 at 16:58
• Ok. Thanks for the explanation (I was wondering about the 1cm part). – Dr. Manuel Kuehner Sep 3 '17 at 17:13