答案1
您的解决方案的替代方案:
与您的解决方案相比,主要区别:
standalone
因为文档类与选项一起使用tikz
。使用它你只能看到图像。当你对结果满意时,你可以将代码复制到最终文档或将其包含在\input{<path>/<picture file name>}
- 样式定义是
tikzpicture
选项的一部分(tikzstyle
现在已不常用,而是更可取\tikzset{...}
,其中样式必须以与tikzpicture
选项中相同的方式定义) - 对于节点样式我宁愿使用我的节点而不是你的节点。 使用节点样式名称不好,因为它已经在 TikZ 中为节点定义了...
- 对于主节点的形状,我选择
signal
。使用它,我可以避免所有正多边形的缩放,并更好地控制形状大小 - 在节点定位中,我更愿意使用相对坐标来协调主节点。在此我利用
positioning
库。它们的距离由node distance = <vertical> and <horizontal>
- 为了绘制箭头,我定义了辅助坐标
scope
箭头按其共同特征(虚线图案、方向)分组- 不是在最后,我在编辑器中编写代码,并查看形状数据TikZ & PGF 手册,第 67 章形状库,第 693 页(形状
signal
在第 67.4 节符号形状中描述,参见第 713 页)。
完成 MWE:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{positioning, shapes.symbols}
\begin{document}
\begin{tikzpicture}[
node distance = 4mm and 16mm,
mynode/.style = {shape=signal, signal to=west and east,
draw, color = #1,
text width=1.3cm, align=flush center,
inner xsep=0mm, inner ysep=2mm, font=\small}
]
% main nodes
\node (A) [mynode=magenta] {Text 2};
\node (B) [mynode=blue, below=of A] {Text 3};
\node (C) [mynode=teal, below=of B] {Text 4};
% coordinates for lines
\coordinate[left=of B.west] (in2);
\coordinate[left=of in2] (in1);
\coordinate[right=of B.east] (out1);
\coordinate[right=of out1] (out2);
% dashed arrows
\begin{scope}[latex-, dashed, shorten >=1mm]
\draw[magenta] (A.west) -- + (-0.8,0) -- (in2);
\draw[blue] (B.west) -- (in2);
\draw[magenta] (C.west) -- + (-0.8,0) -- (in2);
\end{scope}
\begin{scope}[-latex, dashed, shorten >=1mm]
\draw[magenta] (A.east) -- + (0.8,0) -- (out1);
\draw[blue] (B.east) -- (out1);
\draw[magenta] (C.east) -- + (0.8,0) -- (out1);
\end{scope}
% arrows with text
\draw[-latex] (in1) -- node[above] {Text 1} (in2);
\draw[-latex] (out1) -- node[above] {Text 5} (out2);
%--------------
\end{tikzpicture}
\end{document}
答案2
我在 tikzEdit 编辑器的帮助下绘制了(http://www.tikzedt.org/)这是生成该图的代码
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.geometric,shapes.misc}
\begin{document}
\begin{tikzpicture}
%--------------
\tikzstyle{node} = [ regular polygon, regular polygon sides=6,xscale=2,draw,
scale=0.5,text centered,text width=1.3cm,inner sep=0pt]
%--------------
\node (v1) at (-4.5,3.5) {};
\node (v2) at (-3,3.5) {};
\draw [-latex] (v1) -- node[above] {\small Text 1} (v2);
%--------------
\draw [magenta,dashed] (v2) -- (-2.5,5) node (v3) {};
\draw [-latex,magenta,dashed] (v3) -- (-1.5,5);
\node [node,magenta] (A) at (-0.5,5) {\small Text 2};
%--------------
\draw [-latex,blue,dashed] (v2) -- (-1.5,3.5);
\node [node,blue] (B) at (-0.5,3.5) {\small Text 3};
%--------------
\draw [teal,dashed] (v2) -- (-2.5,2) node (v5) {};
\draw [-latex,teal,dashed] (v5) -- (-1.5,2);
\node [node,teal] (C) at (-0.5,2) {\small Text 4};
%--------------
\node (v6) at (2,3.5) {};
\node (v7) at (3.5,3.5) {};
%--------------
\draw [magenta,dashed] (0.6,5) -- (1.5,5) node (v8) {};
\draw [-latex,magenta,dashed] (v8) -- (v6);
\draw [-latex,blue,dashed](0.6,3.5) -- (v6);
\draw [teal,dashed] (0.6,2) -- (1.5,2) node (v9) {};
\draw [-latex,teal,dashed](v9) -- (v6);
%--------------
\draw [-latex] (v6) -- node[above] {\small Text 5} (v7);
%--------------
\end{tikzpicture}
\end{document}