# Tikz: shifting coordinate after arc (and radial color gradient)

Basically, I wanted to create an illustration similar to the bottom rod of this plot:

Following the answers here and here, below is the code for my best attempts. There are two issues:

1. In both attempts, the shift to the left doesn't work as intended. I expected the 1st arc to end at 2*4cm diameter = (8cm, 0), then shift -2cm -> (6cm, 0), then the 2nd arc to end at 6cm-2*2cm diameter = (2cm, 0)
2. I want the color gradient to propogate radially, rather than just from top to bottom.

Code:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\shade[thin, draw=black, top color=blue,bottom color=red]
(0cm,0cm) arc (0:180:4cm) -- +(-2cm,0) arc (180:0:2cm) -- cycle;

\shade[thin, draw=black, top color=blue,bottom color=red]
(0cm,0cm) arc (0:180:4cm) coordinate (a) -- ([xshift=-2cm]a) arc (180:0:2cm) -- cycle;

\end{tikzpicture}
\begin{document}


edit:

• first problem (please, one problem per question :-) )

if i understand your question correctly, than you try to obtain the following image:

i interchange the start/end points of arcs and move coordinate (0,0) to the middle of image:

\documentclass[tikz, margin=3mm]{standalone}

\begin{document}
\begin{tikzpicture}
\shade[thin, draw=black, top color=blue,bottom color=red]
(-4,0) arc (180:0:4cm) -- +(-2,0) arc (0:180:2cm) -- cycle;
\end{tikzpicture}
\end{document}

• second problem

it is not trivial. temporary i'm not able to find satisfactory solution with use of arc. simple replace top color=blue,bottom color=red with inner color=red, outer control=blue doesn't gives what cab be described as radial gradient color.

one way to solve this problem can be use ideas from radial shading as propose May Snippe in his comment below. so far i can only say that solution on such a way require different approach to draw your image:

\documentclass[tikz, margin=3mm]{standalone}

\tikzset{
ring shading/.code args={from #1 at #2 to #3 at #4}{
\def\colin{#1}
\def\colout{#3}
\pgfmathsetmacro{\outer}{.8818cm}
\pgfmathsetmacro{\inner}{.8818cm*\proportion}
\pgfmathsetmacro{\innerlow}{\inner-0.01pt}
{
color(0pt)=(white);
color(\innerlow)=(white);
color(\inner)=(#1);
color(\outer)=(#3)
}
},
}

\begin{document}
\begin{tikzpicture}
\clip  (-4,0) rectangle + (8,4);
\shade[draw,ring shading={from red at 2 to blue at 4}]
(0,0) circle (2) circle (4);
\end{tikzpicture}
\end{document}


which gives:

• three color gradiend coloring, as asked in comment

it is a little bit more complex, since i compose it from two circles' pairs, from which is the second is drawn on background layer. for this you need to add \usetikzlibrary{backgrounds} in document preamble and than the document body write for example as:

\begin{document}
\begin{tikzpicture}
\def\lok{(-4,0) arc (180:0:4cm) -- +(-2,0) arc (0:180:2cm) -- cycle}
\draw \lok;
\clip \lok;
\shade[ring shading={from red at 2 to white at 2.9}]
(0,0) circle (2) circle (2.9);
\begin{scope}[on background layer]
\clip \lok;
\shade[ring shading={from white at 3.1 to blue at 4}]
(0,0) circle (3.1) circle (4);
\end{scope}
\end{tikzpicture}
\end{document}


gives:

as you can see, rings are slightly separated that white transient is thicker. if you prefer narrower white transient, than change radius of outer and inner circles of rings from 2.9 to 3.0 and from 3.1 to 3.0 respectively. with this both rings will touch each other:

• Maybe the second point of OP's question could be solved with radial shading? (+1 of course) – Max Aug 12 '18 at 19:31
• @MaxSnippe, huh, i overlooked this, :-(. i will add this asap :-) – Zarko Aug 12 '18 at 19:33
• @MaxSnippe, adding gradient shading is not so trivial ... it will take me more time :-(. – Zarko Aug 12 '18 at 19:39
• Maybe this question could help? I don't mind, take your time :) I think OP doesn't mind either. – Max Aug 12 '18 at 19:44
• @ChrisSewell, in this case you need to combine two pairs of circles. i will try to do this tomorrow evening. – Zarko Aug 12 '18 at 22:06

I'd use a color wheel for that. With transform canvas you can rotate it. Here is an animation that may help you pick your favorite rotation angle.

\documentclass[tikz, margin=3.14mm]{standalone}