Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
1  
See these answers tex.stackexchange.com/questions/82425/… –  percusse Dec 2 '12 at 15:23
add comment

1 Answer

up vote 5 down vote accepted

You can use this answer and adopt to your situation:

\documentclass[12pt]{article}

\usepackage{tikz}

%Code from Paul Gabroit -- http://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

share|improve this answer
    
Precisely what I needed, thank you. –  Francisco Dec 2 '12 at 16:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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