我正在尝试重现此流程图,但箭头有问题。有什么解决办法吗?
我的尝试。
\begin{tikzpicture}[
node distance = 1.5cm and 2mm,
process/.style = {rectangle, minimum width=6cm, minimum height=2cm, align=center, fill=gray!10}]
\node [process] (a) {Specification and estimation of VAR model}; % A-1
\node [process, below=of a] (b) {Model checking};
\node [process, below=of b] (c) {Forecasting};
\node [process, below right=of b] (d) {Structural analysis}; % A-6
%%
\draw[arrows=-{Stealth[scale=1.2]}, rounded corners, thick]
(a) -- (b)
(b) -| +(2,4) -| +(2,1) -| node {d} (a)
(b) edge (c)
(b) edge (d);
\end{tikzpicture}
\caption{Workflow of VAR Analysis.}
\label{fig:var-workflow}
\end{figure}
答案1
为了练习,由于您的流程图留在树上,我将使用forest
以下包来绘制它forked edge
:
\documentclass[border=3.141592mm]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{forest}
for tree = {
% nodes
draw,
minimum width=22mm, minimum height=12mm,
align = center,
anchor = north,
% tree
grow = south,
forked edge,
edge = {-Stealth, semithick},
s sep = 2mm,
l sep = 8mm,
fork sep = 4mm,
}
[Specification and estimation\\ of VAR model, name=a
[Model checking, name=b
[Forecasting]
[Structural\\ analysis]
]
]
%%
\draw[-Stealth, semithick] (b.east) -- ++(1.5,0) |- (a);
\end{forest}
\end{document}
答案2
假设您在图表末尾做了您想做的事情,下面是处理右箭头的方法。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta}
\begin{document}
\begin{tikzpicture}[
node distance = 1.5cm and 2mm,
process/.style = {rectangle, minimum width=6cm, minimum height=2cm, align=center, fill=gray!10}]
\node [process] (a) {Specification and estimation of VAR model}; % A-1
\node [process, below=of a] (b) {Model checking};
\node [process, below=of b] (c) {Forecasting};
\node [process, below right=of b] (d) {Structural analysis}; % A-6
%%
\draw[arrows=-{Stealth[scale=1.2]}, rounded corners, thick]
(a) -- (b)
(b.east) -| ++(1.5,1) |- (a)
(b) edge (c)
(b) edge (d);
\end{tikzpicture}
\end{document}
答案3
另一个简短的解决方案是使用pstricks
和stackengine
,使用一个简单的tabular
:
\documentclass[svgnames]{article}
\usepackage{array, booktabs}
\usepackage[usestackEOL]{stackengine}
\usepackage{pst-node}%
\newcommand{\chartnode}[2]{\psDefBoxNodes{#1}{\fbox{\quad\Shortunderstack[l]{#2}\quad}}}
\begin{document}
\begin{tabular}{c!{\quad}c}
\multicolumn{2}{c}{\chartnode{V}{Specification and \\ estimation of VAR model}}\\
\addlinespace[6ex]
\multicolumn{2}{c}{\chartnode{M}{Model checking}}\\
\addlinespace[10ex]
\chartnode{F}{Forecasting}& \chartnode{S}{Structural\\ analysis}
%%% arrows
\psset{arrows=->, arrowinset=0.1, linejoin=1, linearc=0.05}
\ncline{V:bC}{M:tC}
\ncbar{M:Cr}{V:Cr}\nbput{\Centerstack[l]{model\\rejected}}
\psset{angleA=-90, angleB=90}
\ncangle{M:bC}{F:tC}\ncangle{M:bC}{S:tC}\naput[npos=0.4]{model accepted}
\end{tabular}
\end{document}
答案4
我没有修改我之前的答案,因为我有一个非常不同的选择。
在和之间是一个简单的图表,这里是节点forest
的使用,其中和。child
sibling distance
level distance
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta}
\begin{document}
\begin{tikzpicture}[
level 1/.style={level distance=3cm},
level 2/.style={level distance=4cm},
sibling distance=5cm,
edge from parent/.style={draw=none},
process/.style = {
rectangle,
minimum width=3.5cm,
minimum height=2cm,
align=center,
fill=gray!10,
inner sep=10pt,
rounded corners=10pt}]
\node [process] (a) {Specification and estimation of VAR model} % A-1
child {node[process] (b) {Model checking}
child {node[process] (c) {Forecasting}}
child {node[process] (d) {Structural analysis}}}; % A-6
\begin{scope}[arrows=-{Stealth[scale=1.2]}, rounded corners, thick]
\draw (a) -- (b);
\draw (b.east) -| ++(2.5,1) |- (a) node[text width=1.5cm, align=center,pos=0.2,right] {model rejected};
\draw (b.south) |-++ (0,-1) node[pos=0.25,right=5pt] {model accepted} -| (c) ;
\draw (b.south) |-++ (0,-1) -| (d) ;
\end{scope}
\end{tikzpicture}
\end{document}