generate simple cylindrical shape with text in latex (tikz)

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}

enter image description here

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}

enter image description here


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}

Three cylinders

Tags:

Tikz Pgf