generate simple cylindrical shape with text in latex (tikz)

I am attempting to generate the following diagram in latex:

I've been using the tikz package, which although its capabilities seem to be endless, it does have a rather steep learning curve. I am currently learning how to generate simple diagrams including circles, arrows, squares, and have no idea how to include text yet. I am working through the manual so I will eventually have a good understanding of the tool, but as of yet, the diagram shown is beyond my capabilities. Could someone specify how I should go around generating this diagram? Many thanks for your help.

• Could you describe more specifically what exactly your question is? As it stands now, it looks a bit like a "please solve my problem" question unlikely to be helpful to future visitors. If you continue working through the manual, you will find out how to draw a diagram like this one (it's not very complicated). Dec 11, 2012 at 15:08
• I think you can start looking at the pgfmanual for the cylinder shape. :) Dec 11, 2012 at 15:12
• Thank you for your comments. Yes, I agree that working through the manual is best, but I am currently on page 38 of the manual and I need to submit some work to my supervisor this evening. Although the diagram is not necessary, it does help illustrate some aspects of my work. My question was basically for someone to show me how to structure all the different shapes and text into one environment. Dec 11, 2012 at 15:44
• @Kate I have provided something for you to start on. Just use the search feature of your pdf reader and search for cylinder. You can add color too if you want but that is up to you to discover. Dec 11, 2012 at 15:46

For starters, you can do something like the one below.

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}[>=latex,shorten >=2pt,shorten <=2pt,shape aspect=1]
\node (A) [cylinder, shape border rotate=90, draw,minimum height=3cm,minimum width=2cm]
{A};
\draw [<->] (A.before top) -- (A.after top) node [midway, above,fill=white] {$A_0$};
\end{tikzpicture}
\end{document}


You can read the appropriate documentation in the pgf manual

You can also manually draw your cylinder like the one below.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) ellipse (1.25 and 0.5);
\draw (-1.25,0) -- (-1.25,-3.5);
\draw (-1.25,-3.5) arc (180:360:1.25 and 0.5);
\draw [dashed] (-1.25,-3.5) arc (180:360:1.25 and -0.5);
\draw (1.25,-3.5) -- (1.25,0);
\fill [gray,opacity=0.5] (-1.25,0) -- (-1.25,-3.5) arc (180:360:1.25 and 0.5) -- (1.25,0) arc (0:180:1.25 and -0.5);
\end{tikzpicture}
\end{document}


• What is the difference between shape border rotate=90 and rotate=90? Is there an argument to adjust how much of the top of the cylinder is displayed? Jun 15, 2019 at 14:42

You can use the tikzlibrary "shapes" as shown here.

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes}

\begin{document}
%\tdplotsetmaincoords{60}{120}
\begin{tikzpicture}

\coordinate (O) at (0,0,0);
\coordinate (A) at (2,0,0);
\coordinate (B) at (0,2,0);
\coordinate (C) at (0,0,2);

% draw axis
\draw[-latex] (O) -- (A) node[below] {$y$};
\draw[-latex] (O) -- (B) node[above] {$z$};
\draw[-latex] (O) -- (C) node[below] {$x$};

\node[cylinder, draw, shape aspect=.5,
cylinder uses custom fill, cylinder end fill=green!50,
minimum height=1cm,
cylinder body fill=green!25, opacity=0.5,
scale=3, rotate=90]{};

\begin{scope}[shift={(4,0)}]

\coordinate (O) at (0,0,0);
\coordinate (A) at (2,0,0);
\coordinate (B) at (0,2,0);
\coordinate (C) at (0,0,3.5);

% draw axis
\draw[-latex] (O) -- (A) node[below] {$y$};
\draw[-latex] (O) -- (B) node[above] {$z$};
\draw[-latex] (O) -- (C) node[below] {$x$};

\node[cylinder, draw, shape aspect=.5,
cylinder uses custom fill, cylinder end fill=green!50,
minimum height=1cm,
cylinder body fill=green!25, opacity=0.5,
scale=3, rotate=-135]{};
\end{scope}
\begin{scope}[shift={(8.,0)}]

\coordinate (O) at (0,0,0);
\coordinate (A) at (2,0,0);
\coordinate (B) at (0,2,0);
\coordinate (C) at (0,0,2);

% draw axis
\draw[-latex] (O) -- (A) node[below] {$y$};
\draw[-latex] (O) -- (B) node[above] {$z$};
\draw[-latex] (O) -- (C) node[below] {$x$};

\node[cylinder, draw, shape aspect=.5,
cylinder uses custom fill, cylinder end fill=green!50,
minimum height=1cm,
cylinder body fill=green!25, opacity=0.5,
scale=3]{};

\end{scope}

\end{tikzpicture}

\end{document}


• Please delete unnecessary packages, only TikZ is useful. Jul 19, 2020 at 18:03
• Good point. Thanks Jul 19, 2020 at 21:45
• why is it not possible to get it smaller than 0.3cm? ie. minimum height=0.3 cm produces the same as minimum height=0.1 cm Sep 27, 2021 at 9:09