我在将箭头移至“过程模型”时遇到问题,以便为另一个从“测量过程”到“过程模型”的箭头腾出空间(通过一堆未包含的其他框)。
我可能可以通过移动箭头肘部的中间节点来实现这一点,但这似乎是一个糟糕的黑客行为。有什么更好的建议吗?
另外,有没有更好的方法来增加全部箭头?的使用postaction
也感觉有点“黑客”。
以下是最小工作示例:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\tikzset{
joinnode/.style={draw, circle, fill=black, minimum size=0.15cm, inner sep=0cm},
boxnode/.style={draw, fill=white, minimum width=2cm, minimum height=1.2cm, align=center}
}
\begin{document}
\begin{tikzpicture}[decoration={
markings,
mark=at position 1 with {\arrow[scale=2,black]{stealth}};
}
]
\node[boxnode] (process) at (0,0) {Process};
\node (startnode) at (-5,0) {};
\draw[postaction={decorate}] (startnode.east) -- (process.west) node[midway,above] {Input data} node[midway,joinnode] (input) {};
%\node [jointnode, right=1.5cm of process] (node1) {};
\draw[postaction={decorate}] (process.east) -- (5,0) node[midway, above] {Sensor Data} node[pos=0.7, joinnode] (node1) {};
\node[boxnode, below=1cm of node1] (measure) {Measurement\\ Processing};
\draw[postaction={decorate}] (node1) -- (measure.north);
\node[boxnode, below=2.5cm of process] (model) {Process\\ Model};
\node[inner sep=0cm, minimum width=0cm] at (input |- model) (node2) {};
\draw (input) -- ([yshift=+0.25cm]node2);
\draw[postaction={decorate}] (node2) -- ([yshift=+0.25cm]model.west);
\end{tikzpicture}
\end{document}
答案1
首先,如果您绘制路径而|-
不是连接中间节点,它会在包括目标节点的 yshift 的位置处创建一个具有矩形角度的路径。
其次,使用 tikz 库 arrows.meta,您可以配置没有后期操作的箭头(例如,scale
或length
和width
)。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings, arrows.meta}
\tikzset{
joinnode/.style={draw, circle, fill=black, minimum size=0.15cm, inner sep=0cm},
boxnode/.style={draw, fill=white, minimum width=2cm, minimum height=1.2cm, align=center}
}
\begin{document}
\begin{tikzpicture}
\node[boxnode] (process) at (0,0) {Process};
\node (startnode) at (-5,0) {};
\draw[-{Stealth[scale=2]}] (startnode.east) -- (process.west) node[midway,above] {Input data} node[midway,joinnode] (input) {};
\draw[-{Stealth[scale=2]}] (process.east) -- (5,0) node[midway, above] {Sensor Data} node[pos=0.7, joinnode] (node1) {};
\node[boxnode, below=1cm of node1] (measure) {Measurement\\ Processing};
\draw[-{Stealth[scale=2]}] (node1) -- (measure.north);
\node[boxnode, below=2.5cm of process] (model) {Process\\ Model};
\draw[-{Stealth[scale=2]}] (input) |- ([yshift=+0.25cm]model.west);
\end{tikzpicture}
\end{document}
输出: