3

I need to draw a circle that represents a density that's constant up to a certain value of radius, then begins to descend. What I mean, is something like this:

\documentclass[12pt]{article}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\shade [shading=radial,inner color=black] (0,4) circle (2cm);
\draw [fill=lightgray] (0,4) circle (1cm);

\draw[->] [very thick] (0,0) -> (0,2);
\draw[->] [very thick] (0,0) -> (3,0);

\draw [dotted] (0,2) -> (0,4);
\draw [dotted] (1,0) -> (1,4);
\draw [dotted] (2,0) -> (2,4);

\draw [thick] (0,.25) -- (1,.25) -- (1,1.35) -- 
              (1.25,1.35) .. controls (1.625,1.35) 
              and (1.625,0) .. (2,0);

\draw (-.2,1.7) node {$\rho$};
\draw (1,-.2) node {$R_{in}$};
\draw (2,-.2) node {$R_{out}$};
\draw (3.1,-.2) node {$R$};


\end{tikzpicture}

\end{document}

Which produces this:

What I managed to produce so far

What I want is this:

Circle with darker outer shading

Notice how the line of the circle matches the shade's starting color. I though I could do this by setting an "intermediate color" for the shade, but this option doesn't seem to exist.

Ideally the shade should follow closely the plot in the bottom of the first figure, but I consider that as a bonus.

Francisco
  • 824

1 Answers1

6

You can use this answer and adopt to your situation:

\documentclass[12pt]{article}

\usepackage{tikz}

%Code from Paul Gabroit -- https://tex.stackexchange.com/a/82503/11232
%%%%%%%%%%%%%%%%%%%%%%%%%
\tikzset{
  ring shading/.code args={from #1 at #2 to #3 at #4}{
    \def\colin{#1}
    \def\radin{#2}
    \def\colout{#3}
    \def\radout{#4}
    \pgfmathsetmacro{\proportion}{\radin/\radout}
    \pgfmathsetmacro{\outer}{.8818cm}
    \pgfmathsetmacro{\inner}{.8818cm*\proportion}
    \pgfmathsetmacro{\innerlow}{\inner-0.01pt}
    \pgfdeclareradialshading{ring}{\pgfpoint{0cm}{0cm}}%
    {
      color(0pt)=(white);
      color(\innerlow)=(white);
      color(\inner)=(#1);
      color(\outer)=(#3)
    }
    \pgfkeysalso{/tikz/shading=ring}
  },
}
%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\begin{tikzpicture}
\shade[even odd rule,ring shading={from black at 1 to white at 2}]
  (0,4) circle (2) ;
%\shade[shading=radial,inner color=black](0,4) circle (2cm);
\draw [fill=lightgray] (0,4) circle (1cm);

\draw[->] [very thick] (0,0) -> (0,2);
\draw[->] [very thick] (0,0) -> (3,0);

\draw [dotted] (0,2) -> (0,4);
\draw [dotted] (1,0) -> (1,4);
\draw [dotted] (2,0) -> (2,4);

\draw [thick] (0,.25) -- (1,.25) -- (1,1.35) --
              (1.25,1.35) .. controls (1.625,1.35)
              and (1.625,0) .. (2,0);

\draw (-.2,1.7) node {$\rho$};
\draw (1,-.2) node {$R_{in}$};
\draw (2,-.2) node {$R_{out}$};
\draw (3.1,-.2) node {$R$};


\end{tikzpicture}

\end{document}

enter image description here