I have the following line using \draw (see MWE below). I would like to have the line change in color, from red on the right, to blue on the left. Current attempts are adding a fading region rather than changing the color of the line itself.

Note that this solution by percusse offers a solution, using a custom fade, but I'm not sure how to edit it to get the effect I'm looking for. I would ideally like to add an edit to \draw[...] that achieves this effect.




\draw [ultra thick,red] (-19.5,-16) to[out=55,in=228] (-14,-9) to [out=45,in=180] (0,-2) to[out=0,in=135] (14, -9) to[out=315,in=125] (20,-16);       


If you want it shaded I have a (dirty) but quick solution. Use shade and add a filled white version in front:




    \fill[fill=white] (-19.35,-16.01) to[out=55,in=228] (-13.8,-9) to [out=45,in=180] (0,-2.15) to[out=0,in=135] (13.8, -9) to[out=315,in=125] (19.85,-16.01); 
            \shade[left color=blue, right color=red, very thick] (-19.5,-16) to[out=55,in=228] (-14,-9) to [out=45,in=180] (0,-2) to[out=0,in=135] (14, -9) to[out=315,in=125] (20,-16);  


This is the effect I think you are looking for without any custom fading. enter image description here

  • The later answer was indeed what I was looking for
    – Sid
    Jul 13 at 8:54
  • Is it possible to add a left opacity and right opacity? I'm looking for a bit more control that path fading=west. Something that controls where the fading/opacity starts
    – Sid
    Jul 13 at 10:22

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.