在乳胶(tikz)中生成带有文本的简单圆柱形状

在乳胶(tikz)中生成带有文本的简单圆柱形状

我正在尝试在乳胶中生成下图:

在此处输入图片描述

我一直在使用 tikz 包,虽然它的功能似乎无穷无尽,但学习起来确实很困难。我目前正在学习如何生成简单的图表,包括圆形、箭头、正方形,但还不知道如何添加文本。我正在阅读手册,以便最终能够很好地理解该工具,但到目前为止,显示的图表超出了我的能力范围。有人可以具体说明我应该如何生成此图表吗?非常感谢您的帮助。

答案1

首先,您可以执行以下操作。

\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}

在此处输入图片描述

您可以在pgf 手册

您还可以手动绘制圆柱体,如下所示。

\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}

在此处输入图片描述

答案2

您可以使用 tikzlibrary“形状”,如下所示。

\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}

三缸

相关内容