I'm trying to use tikz to create the attached image, but I'm not sure this is possible. I know I can use the package to draw cylinders, as shown here and here. But I don't think I can use the \usetikzlibrary{shapes} to provide the cut shown in the attachment. Is this at all feasible with tikz?

enter image description here


This draws such a cylinder and also uses patterns.meta for the ellipses.

\def\pk#1{\pgfkeysvalueof{/pgf/pattern keys/#1}}
      \pk{line width},
  bounding box={(-.1pt,-.1pt) and
  tile size={(\pk{size},
  tile transformation={rotate=\pk{angle}},
    line width/.initial=.4pt,
}, code={
\draw[line width=\pk{line width}] 
(0,0) -- ({\pk{size}},0) ;
} }
 \draw[fill=gray!30] (0,\pv{r}) 
    arc[start angle=90,end angle=270,x radius=\pv{r}*\pv{aspect},y radius=\pv{r}]
    -- (\pv{h},-\pv{r}) to[out=180,in=-120] 
    (\pv{h},0) to[out=60,in=0] (\pv{h},\pv{r}) -- cycle;
 \draw[fill=gray!60]  (\pv{h},-\pv{r}) to[out=180,in=-120]  (\pv{h},0)
 to[out=-60,in=0] cycle;
 \draw[fcylinder/finish] (0,\pv{r}) 
  arc[start angle=90,end angle=-90,x radius=\pv{r}*\pv{aspect},y radius=\pv{r}];
 \begin{scope}[local bounding box=Dirichlet]
  \path[pattern={lines[line width=.8pt,angle=30]}] 
  (0,0) circle[x radius=5mm,y radius=1.5cm]; 
  \path (0,0) pic{fcylinder={finish/.style=dashed}};
 \begin{scope}[xshift=3.5cm,local bounding box=Neumann]
  \path (0,0) pic{fcylinder};
  \draw[very thick,-stealth] (0,0) -- node[above] {$\bar N$}++ (-1,0);
 \begin{scope}[xshift=7cm,local bounding box=Robin]
  \path[pattern={lines[line width=.8pt,angle=30]}] 
  (0,0) circle[x radius=5mm,y radius=1.5cm]; 
  \path (1,0) pic{fcylinder};
  \draw[thick,decorate,decoration={zigzag,segment length=1.5mm,amplitude=2mm,
  pre length=2mm,post length=2mm}] (0,0) -- (1,0);

enter image description here

  • Fantastic, how did you come up with that parametrization for the cylinder? – N3buchadnezzar Jan 28 at 13:52
  • @N3buchadnezzar Just guessing. (Surprisingly the first thing I tried looked reasonable so I took it.) – Schrödinger's cat Jan 28 at 14:05

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.