TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

can someone provide me with some code, or insights, into how to create a diagram of a shaded cylinder within a cylinder? any typesetting system will do (please specify which one, though).

is it also possible to label the regions? like, with letters (cylinder C, smaller cylinder P, lengthwise T, etc)? any answers or references to existing answers would be much appreciated. thank you!

share|improve this question
up vote 4 down vote accepted

If I understand you correctly, following code may be help you.


  dim above/.style={to path={\pgfextra{
        \draw[>=latex,|<->|] let
        in(\p1) -- (\p2) node[pos=.5,sloped,above]{#1};
      }(\tikztostart) -- (\tikztotarget) \tikztonodes
  dim below/.style={to path={\pgfextra{
        \draw[>=latex,|<->|] let 
        in (\p1) -- (\p2) node[pos=.5,sloped,below]{#1};
      }(\tikztostart) -- (\tikztotarget) \tikztonodes


\draw[thick,-latex] (0,0,0) -- (4,0,0) node[anchor=north east]{$y$};
\draw[thick,-latex] (0,0,0) -- (0,7.5,0) node[anchor=north west]{$z$};
\draw[thick,-latex] (0,0,0) -- (0,0,5) node[anchor=south east]{$x$};

\fill[top color=gray!50!black,bottom color=blue!10,middle color=gray,shading=axis,opacity=0.25] (0,0) circle (2cm and 0.5cm);
\fill[left color=gray!50!black,right color=blue!50!black,middle color=gray!50,shading=axis,opacity=0.25] (2,0) -- (2,4) arc (360:180:2cm and 0.5cm) -- (-2,0) arc (180:360:2cm and 0.5cm);
\fill[top color=blue!90!,bottom color=blue!2,middle color=blue!30,shading=axis,opacity=0.25] (0,4) circle (2cm and 0.5cm);
\draw (-2,4) -- (-2,0) arc (180:360:2cm and 0.5cm) -- (2,4) ++ (-2,0) circle (2cm and 0.5cm);
\draw[densely dashed] (-2,0) arc (180:0:2cm and 0.5cm);

\fill[top color=gray!50!black,bottom color=orange!10,middle color=gray,shading=axis,opacity=0.5] (0,0) circle (1.5cm and 0.25cm);
\fill[left color=gray!50!black,right color=orange!50!black,middle color=gray!50,shading=axis,opacity=0.25] (2,0) -- (2,4) arc (360:180:2cm and 0.5cm) -- (-2,0) arc (180:360:2cm and 0.5cm);
\fill[top color=blue!90!,bottom color=orange!2,middle color=orange!30,shading=axis,opacity=0.25] (0,4) circle (1.5cm and 0.25cm);
\draw (-1.5,4) -- (-1.5,0) arc (180:360:1.5cm and 0.25cm) -- (1.5,4) ++ (-1.5,0) circle (1.5cm and 0.25cm);
\draw[densely dashed] (-1.5,0) arc (180:0:1.5cm and 0.25cm);

\draw (-2,0) to[dim above=$T$,color=orange] (-2,4) ;
\node at (-1.75,4) {$C$};
\node at (-0.75,4) {$P$};

enter image description here

share|improve this answer
sir/madam! that is amazing! thank you so so so much! just out of curiosity, if i wanted to take away the axes, which part of the code should i subtract? – Gordon Feb 15 '14 at 20:46
Delete 3 lines after \begin{tikzpicture}. – ferahfeza Feb 15 '14 at 20:48
i am forever in your debt. thank you!! – Gordon Feb 15 '14 at 20:52
@Gordon, your welcome. – ferahfeza Feb 15 '14 at 20:54

Your Answer


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.