1

I have something like the following:

\begin{tikzpicture}
\draw [draw=gray, ultra thick]plot [smooth cycle] coordinates {
(6+0.3,-0.5) (6+0.3,1.5-0.2)(7+0.3,1.5)(7+0.3,2.5)(6+0.3,2.5+0.2) (6+0.3,5.5)(6+0.1,5.5)(6+0.1,-0.5)
};

\end{tikzpicture}

that creates something like a Gaussian (yeah, its not, and neither is intended to be, but kind of looks like one).

How can I fill this figure with a gradient that is higher in the highest point? I can make it user defined, no need for maths, e.g. Lighter (or darker) part to be on y=2.

6
  • You can add top color=yellow,bottom color=black to draw options\
    – percusse
    Commented Oct 20, 2016 at 12:06
  • @percusse Can you add more? E.g medium color? Commented Oct 20, 2016 at 12:08
  • yes it is called middle color. More options are in the PGF/TikZ manual about shadings.
    – percusse
    Commented Oct 20, 2016 at 12:10
  • I'm on the phone now. If anyone else doesn't write it, I'll make a MWE later in the day :)
    – percusse
    Commented Oct 20, 2016 at 12:15
  • @percusse But that only works for a single "direction" shading. I can not say top,middle,bottom it will ignore middle Commented Oct 20, 2016 at 12:18

1 Answer 1

2

You can use one of the default shadings here which is automatically enabled if you use top color=yellow (or bottom). If you want to use a middle color you have to declare it after these keys since the other two overwrites the middle color. This is because you can use only one key to enable a shading and they automatically fill the middle color by interpolation. From the manual

Note: Since both top color and bottom color change the middle color, this option should be given last if all of these options need to be given

In this case the output is

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw [draw=gray, ultra thick,top color=yellow,bottom color=black,middle color=white]
    plot [smooth cycle] coordinates {
(6+0.3,-0.5) 
(6+0.3,1.5-0.2)
(7+0.3,1.5)
(7+0.3,2.5)
(6+0.3,2.5+0.2)
(6+0.3,5.5)
(6+0.1,5.5)
(6+0.1,-0.5)
};
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .