使用 TikZ 对带标签的圆柱体进行两种修改

使用 TikZ 对带标签的圆柱体进行两种修改

我正在尝试使用 TikZ(我仍在学习)构建类似以下两张图片的东西:

带标签的圆柱体修改

图片只是示意图,不需要阴影。有人能帮帮我吗?

答案1

以下是使用cylinder形状的一个基本方法:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\tikzset{
  mycil/.style={
    cylinder,
    rotate=#1,
    draw,
    minimum height=2cm,
    minimum width=1.25cm,
    cylinder uses custom fill=true,
    cylinder end fill=gray!30,
    anchor=south west
    },
  mytext/.style={
    draw,
    align=center,
    minimum width=1.5cm,
    minimum height=1cm
    },
  >=latex    
}
\begin{document}

\begin{tikzpicture}
\draw[->]
  (-3,-1) -- node[left] {$t$} (-3,7);
\draw
  (3,-1) -- (-3,-1) -- ++(45:3cm);
\node[mycil=45,anchor=south west]
  at (1,5) 
  (cilright) {};
\node[mycil=135,anchor=north west]
  at (-1,5) 
  (cilleft) {};
\filldraw[draw=none,fill=white]
   (-1,0) -- (-1,0|-cilleft.before bottom) -- (1,0|-cilleft.before bottom) -- (1,0);
\draw
   (cilleft.135) -- ++(0,-5) arc[start angle=180,end angle=360,x radius=1cm,y radius=5pt] -- (cilright.225);
\node[mytext]
  at ([yshift=1.5cm]cilleft.top)
  (text1)
  {Text 1};
\node[mytext]
  at ([yshift=1.5cm]cilright.top)
  (text2)
  {Text 2};
\draw[->]
  (text1) -- ([yshift=-5pt]cilleft.top);  
\draw[->]
  (text2) -- ([yshift=-5pt]cilright.top);  

\draw[->]
  (5,-1) -- node[left] {$t$} (5,7);
\draw
  (11,-1) -- (5,-1) -- ++(45:3cm);
\node[mycil=90,minimum height=6cm,minimum width=2cm,anchor=west]
  at (8,0) 
  (cilup) {};
\node[mycil=5,anchor=west,yslant=0.6]
  at ([xshift=10pt]cilup.center) 
  (cildiag) {};
\node[mytext]
  at ([yshift=1.5cm]cilup.top)
  (text3)
  {Text 3};
\node[mytext]
  at ([xshift=1.5cm]cildiag.top)
  (text4)
  {Text 4};
\draw[->]
  (text3) -- ([yshift=-5pt]cilup.top);  
\draw[->]
  (text4) -- ([xshift=-5pt]cildiag.top);  

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容