Take for example my code from https://tex.stackexchange.com/a/497174/191567
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzset{
bloc/.style={
anchor=south west,
draw,
minimum height=0.7cm,
align=left,
font=\small
},
}
\begin{tikzpicture}
\pgfdeclarehorizontalshading{myshadingA}{3cm}{
color(0cm)=(green);
color(1.44cm)=(green);
color(1.8cm)=(red)
}
\node[bloc, minimum width=5.5cm,
shading=myshadingA]
at (-9,0.5) {Initialize process};
\end{tikzpicture}
\end{document}
I found out to place the end of the pgfshading at about 1.8cm by trial and error. Naively I would would have assumed it to end at 5.5cm, the width of the node. Why the different location?
EDIT:
Changing the vertical size from 3cm to something else does not seem to affect the dimension required in horizontal direction
\pgfdeclarehorizontalshading{myshadingA}{3cm}{.... – Jun 24 '19 at 22:14