I want to fill a rectangle with a continuum of colors. I want the color on the left to be black and the color on the right to be white. In between, there are different shades of gray.

This part is similar to the already answered question Color gradient in tikzpicture from top to bottom corner.

I also want there to be several vertical arrows with small labels like "A", "B", "C", and so on. These arrows are below and above the rectangle and do not extend to the borderlines of the rectangle. In the following figure, I have created an example of how I want the rectangle to look.

Rectangle with gray color continuum, arrows with labels above and beneath the rectangle

The rectangle should be an independent object. It should not have an axis.

What could a minimal worked example look like that uses the packages tikz/pgf?

  • The answer of the link is not complete. Omitted arrows and letters. I have the complete answer. Apr 1 at 8:39
  • @RaffaeleSantoro, the question is "open" again ... Apr 1 at 18:51

1 Answer 1


Try this code:

        \shade[left color=black,right color=white] (0,0) rectangle(14,2);
        \draw[stealth-] (8.4,2.2)--(8.4,2.8) node[above] () {$C$};
        \draw[stealth-] (5.6,2.2)--(5.6,2.8) node[above] () {$B$};
        \draw[stealth-] (2.8,-0.2)--(2.8,-0.8) node[below] () {$A$};
        \draw[stealth-] (10.5,-0.2)--(10.5,-0.8) node[below] () {$D$};
        \draw[stealth-] (12.6,-0.2)--(12.6,-0.8) node[below] () {$E$};

The output is:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.