在序言中这样写道:
\usepackage{tikz}
\usetikzlibrary{chains,shapes.multipart}
\usetikzlibrary{scopes}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{shapes,calc}
\usetikzlibrary{automata,positioning}
我有下图:
\begin{figure}
\centering
\begin{tikzpicture}[start chain=going right,>=latex,node distance=0pt]
\node[draw,rectangle,on chain,minimum size=1.5cm] (rr) {$I$};
\node[draw,rectangle,on chain,draw=white,minimum size=0.8cm]{};
% the rectangular shape with vertical lines
\node[rectangle split, rectangle split parts=5,
draw, rectangle split horizontal,text height=1cm,text depth=0.5cm,on chain,inner ysep=0pt] (wa) {};
\fill[white] ([xshift=-\pgflinewidth,yshift=-\pgflinewidth]wa.north west) rectangle ([xshift=-15pt,yshift=\pgflinewidth]wa.south);
\node at (wa.east) (A){};
\draw [-latex] (A) --+(30:1.5) coordinate (B1);
\draw [-latex] (A) --+(-30:1.5) coordinate (B2);
% the circle
\node [draw,circle,on chain,minimum size=1cm] at (B1) (se1) {$U_1$};
\draw [-latex] (se1) --+(0:1.3) coordinate (BB1);
\node [draw,circle,on chain,minimum size=1cm] at (B2) (se2) {$U_2$};
\draw [-latex] (se2) --+(0:1.3) coordinate (BB2);
\node [draw,diamond,on chain,minimum size=0.2cm] at (BB1) (C3){};
\draw [-latex] (C3)--+(0:1)node[midway,above] {$\mu$};
% the arrows and labels
\draw[<-] (wa.west) -- +(-20pt,0) node[midway,below] {$\lambda$};
\draw[->] (C3.north) to[out=120, in=145] ([shift=(up:.3)] wa.west);
\end{tikzpicture}
\caption{The model represented as a queuing system.}
\label{fig:queue}
\end{figure}
如何在没有箭头的地方添加标签(下图显示了我想要添加标签的边缘)?
答案1
转换我的评论答案:
在曲线路径上,节点规范必须遵循to
。因此,示例中的相关行应为:
\draw[->] (C3.north) to[out=120, in=145] node[below] {<label text>} ([shift=(up:.3)] wa.west);
还要注意,对于这个特定示例,您加载的许多库都不是必需的;只有chains
和shapes
(包括shapes.multipart
)是必需的。
代码
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains,shapes}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[start chain=going right,>=latex,node distance=0pt]
\node[draw,rectangle,on chain,minimum size=1.5cm] (rr) {$I$};
\node[draw,rectangle,on chain,draw=white,minimum size=0.8cm]{};
% the rectangular shape with vertical lines
\node[rectangle split, rectangle split parts=5,
draw, rectangle split horizontal,text height=1cm,text depth=0.5cm,on chain,inner ysep=0pt] (wa) {};
\fill[white] ([xshift=-\pgflinewidth,yshift=-\pgflinewidth]wa.north west) rectangle ([xshift=-15pt,yshift=\pgflinewidth]wa.south);
\node at (wa.east) (A){};
\draw [-latex] (A) --+(30:1.5) coordinate (B1);
\draw [-latex] (A) --+(-30:1.5) coordinate (B2);
% the circle
\node [draw,circle,on chain,minimum size=1cm] at (B1) (se1) {$U_1$};
\draw [-latex] (se1) --+(0:1.3) coordinate (BB1);
\node [draw,circle,on chain,minimum size=1cm] at (B2) (se2) {$U_2$};
\draw [-latex] (se2) --+(0:1.3) coordinate (BB2);
\node [draw,diamond,on chain,minimum size=0.2cm] at (BB1) (C3){};
\draw [-latex] (C3)--+(0:1)node[midway,above] {$\mu$};
% the arrows and labels
\draw[<-] (wa.west) -- +(-20pt,0) node[midway,below] {$\lambda$};
\draw[->] (C3.north) to[out=120, in=145] node[below] {$X$} ([shift=(up:.3)] wa.west); % <<< additions here
\end{tikzpicture}
\caption{The model represented as a queuing system.}
\label{fig:queue}
\end{figure}
\end{document}