在这个问题,我尝试了以下解决方案
\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\usepackage{tikz}
\begin{document}
\begin{minipage}{\textwidth}
\begin{tikzpicture}[scale=.5, transform shape]
\node [thin, black] (0,0) (origin){}
([shift={(0.:1.2)}]origin.center) node (txtu){}
([shift={(-65.:4.)}]origin.center) node (txtd){}
([shift={(180.:7.)}]txtd.center) node (txtds){}
([shift={(180.:5.8)}]txtds.center) node (txtdt){}
([shift={(-90.:.4)}]origin.center) node (od){}
([shift={(180.:5.)}]od.center) node (odsens){}
([shift={(-90.:9.8)}]odsens.center) node (odsensd){}
([shift={(0.:.12)}]od.center) node (odr){}
([shift={(0.:3.)}]od.center) node (odrr){}
([shift={(180.:.12)}]od.center) node (odl){}
([shift={(180.:1.)}]od.center) node (odll){}
([shift={(180.:.2)}]odll.center) node (odlll){}
([shift={(-90.:.26)}]odrr.center) node (odrrd){}
([shift={(-90.:.12)}]odll.center) node (odllc){}
([shift={(-90.:.24)}]odll.center) node (odlld){}
([shift={(-90.:1.)}]origin.center) node (originb){}
([shift={(0.:1.2)}]originb.center) node (txtub){}
([shift={(-65.:4.)}]originb.center) node (txtdb){}
([shift={(180.:7.)}]txtdb.center) node (txtdsb){}
([shift={(180.:5.8)}]txtdsb.center) node (txtdtb){}
([shift={(-90.:.4)}]originb.center) node (odb){}
([shift={(180.:5.)}]odb.center) node (odsensb){}
([shift={(-90.:9.8)}]odsensb.center) node (odsensdb){}
([shift={(0.:.12)}]odb.center) node (odrb){}
([shift={(0.:3.)}]odb.center) node (odrrb){}
([shift={(180.:.12)}]odb.center) node (odlb){}
([shift={(180.:1.)}]odb.center) node (odllb){}
([shift={(-90.:.26)}]odrrb.center) node (odrrdb){}
([shift={(-90.:.12)}]odllb.center) node (odllcb){}
([shift={(-90.:.24)}]odllb.center) node (odlldb){}
([shift={(-90.:2.)}]origin.center) node (originc){}
([shift={(0.:1.2)}]originc.center) node (txtuc){}
([shift={(-65.:4.)}]originc.center) node (txtdc){}
([shift={(180.:7.)}]txtdc.center) node (txtdsc){}
([shift={(180.:5.8)}]txtdsc.center) node (txtdtc){}
([shift={(-90.:.4)}]originc.center) node (odc){}
([shift={(180.:5.)}]odc.center) node (odsensc){}
([shift={(-90.:9.8)}]odsensc.center) node (odsensdc){}
([shift={(0.:.12)}]odc.center) node (odrc){}
([shift={(0.:3.)}]odc.center) node (odrrc){}
([shift={(180.:.12)}]odc.center) node (odlc){}
([shift={(180.:1.)}]odc.center) node (odllc){}
([shift={(-90.:.26)}]odrrc.center) node (odrrdc){}
([shift={(-90.:.12)}]odllc.center) node (odllcc){}
([shift={(-90.:.24)}]odllc.center) node (odlldc){}
([shift={(180.:.2)}]odlldc.center) node (odlldlc){}
;
\draw[thick, purple!60!black, top color=red, bottom color=red, middle color=red!60, opacity=.4] (odr.center) -- ([shift={(90.:.4)}]odr.center) .. controls (40:1.2) and (140:1.2) .. ([shift={(90.:.4)}]odl.center) -- (odl.center)
(odrb.center) -- ([shift={(90.:.4)}]odrb.center) .. controls (40:1.2) and (140:1.2) .. ([shift={(90.:.4)}]odlb.center) -- (odlb.center)
(odrc.center) -- ([shift={(90.:.4)}]odrc.center) .. controls (40:1.2) and (140:1.2) .. ([shift={(90.:.4)}]odlc.center) -- (odlc.center)
;
\draw[thick, purple!60!black, top color=red, bottom color=red, middle color=red!60, opacity=.4] ([shift={(180.:.02)}]odr.center) -- (odrr.center) -- (odrrd.center) -- (odlld.center) -- (odll.center) -- ([shift={(0.:.02)}]odl.center);
\draw[thick, purple!60!black, top color=red, bottom color=red, middle color=red!60, opacity=.4] ([shift={(180.:.02)}]odrb.center) -- (odrrb.center) -- (odrrdb.center) -- (odlldb.center) -- (odllb.center) -- ([shift={(0.:.02)}]odlb.center);
\draw[thick, purple!60!black, top color=red, bottom color=red, middle color=red!60, opacity=.4] ([shift={(180.:.02)}]odrc.center) -- (odrrc.center) -- (odrrdc.center) -- (odlldc.center) -- (odllc.center) -- ([shift={(0.:.02)}]odlc.center);
\end{tikzpicture}
\end{minipage}
\end{document}
这让我画出了下面的图
我怎样才能避免拉长的圆形,使它看起来像这样
稍后我想把它们连接起来,看起来像这张图
答案1
你对这三种形状使用完全相同的控制点。也就是说,当你
.. controls (40:1.2) and (140:1.2) ..
(40:1.2)
并且(140:2)
处于相同位置,它们与路径上的前一个点没有关系。要解决这个问题,请使用相对坐标,如下所示
.. controls +(40:1.2) and +(140:1.2) ..
仅供参考,如果我没记错的话,当你这样做的时候
(a_x, a_y) .. controls +(x1,y1) and +(x2,y2) .. (b_x, b_y)
两个控制点分别位于(a_x+x1, a_y+y1)
和(b_x+x2, b_y+y2)
。
附录
根据您的需要,绘制这些形状的不同方法可能更容易处理。例如,您可以使用pic
这样的方法:
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\tikzset{
myshape/.pic={
\draw[thick,
purple!60!black,
top color=red,
bottom color=red,
middle color=red!60,
opacity=.4]
(0,0) coordinate (-ll) |- (0.6,0.2) -- (0.6,0.3)
.. controls +(140:0.6) and +(40:0.6) .. coordinate [midway] (-top)
(0.8,0.3) |- (2.2,0.2) coordinate (-ur) |- (0,0);
}
}
\begin{document}
\begin{tikzpicture}
\foreach \y in {0,1,2}
\pic (s-\y) at (0,0.65*\y) {myshape};
\draw (s-0-top) to[bend right] (s-2-ur);
\end{tikzpicture}
\end{document}
这个特定版本并不完全复制您的图表,但它更容易更改,因为您只需要更改其定义,pic
它的所有三个实例都会更改。