我使用以下代码绘制了左侧描述的流程图...但是,我想按照左侧描述的方式进行绘制。我想将箭头向左/向右移动,而不是在 L - BFGS 框的中心移动。
你好,我想制作一个如上图右侧所示的流程图。例如,一个箭头从 L BFGS 向下指向 AKR & Gradient,然后另一个箭头从 AKR 向上指向 L BFGS。向下的箭头位于矩形的左侧,而向上的箭头位于矩形的右侧。
关于我分享的代码,我该如何编辑它?
代码如下:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{startstop} = [rectangle, rounded corners,
minimum width=3cm,
minimum height=0.9cm,
text centered,
draw=black,
fill=white]
\tikzstyle{second} = [rectangle, rounded corners,
minimum width=1.5cm,
minimum height=0.7cm,
text centered,
draw=black,
fill=white]
\tikzstyle{optimizer} = [rectangle, rounded corners,
minimum width=4cm,
minimum height=1.2cm,
text centered,
draw=black,
fill=white]
\tikzstyle{true} = [rectangle, rounded corners,
minimum width=1.5cm,
minimum height=0.7cm,
text centered,
draw=black,
fill=white]
\tikzstyle{io} = [trapezium,
trapezium stretches=true, % A later addition
trapezium left angle=90,
trapezium right angle=90,
minimum width=5cm,
minimum height=1.5cm, text centered,
draw=black, fill=white]
\tikzstyle{process} = [rectangle,
minimum width=3cm,
minimum height=1cm,
text centered,
text width=3cm,
draw=black,
fill=orange!30]
\tikzstyle{decision} = [diamond,
minimum width=3cm,
minimum height=1cm,
text centered,
draw=black,
fill=green!30]
\tikzstyle{arrow} = [thin,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=2.0cm]
\node (start) [startstop] {Initial $S_{wo}$,\:$P_{eo}$};
\node (sec) [second, below of=start] {$m_{S_w}$,\:$m_{P_e}$};
\node (bfg) [optimizer, right of=sec, xshift=2.0cm] {\textbf{L - BFGS}};
\node (tr) [second, below of=bfg, node distance=3cm] {$S_w$,\:$P_e$};
\node (aki) [io, below of=tr, node distance=3cm] {\textbf{AKR \& Gradient}};
\draw [arrow] (start) -- node[anchor=west] {$L$} (sec);
\draw [arrow] (sec) -- (bfg);
\draw [arrow] (bfg) -- node[anchor=west] {$L^{-1}$} (tr);
\draw [arrow] (tr) -- (aki);
\end{tikzpicture}
\end{document}
答案1
一些化妆品给@miltos 的回答:
代码:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{startstop} = [rectangle, rounded corners,
minimum width=3cm,
minimum height=0.9cm,
text centered,
draw=black,
fill=white]
\tikzstyle{second} = [rectangle, rounded corners,
minimum width=1.5cm,
minimum height=0.7cm,
text centered,
draw=black,
fill=white]
\tikzstyle{optimizer} = [rectangle, rounded corners,
minimum width=4cm,
minimum height=1.2cm,
text centered,
draw=black,
fill=white]
\tikzstyle{true} = [rectangle, rounded corners,
minimum width=1.5cm,
minimum height=0.7cm,
text centered,
draw=black,
fill=white]
\tikzstyle{io} = [trapezium,
trapezium stretches=true, % A later addition
trapezium left angle=90,
trapezium right angle=90,
minimum width=5cm,
minimum height=1.5cm, text centered,
draw=black, fill=white]
\tikzstyle{process} = [rectangle,
minimum width=3cm,
minimum height=1cm,
text centered,
text width=3cm,
draw=black,
fill=orange!30]
\tikzstyle{decision} = [diamond,
minimum width=3cm,
minimum height=1cm,
text centered,
draw=black,
fill=green!30]
\tikzstyle{arrow} = [thin,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=2.0cm]
\node (start) [startstop] {Initial $S_{wo}$,\:$P_{eo}$};
\node (sec) [second, below of=start] {$m_{S_w}$,\:$m_{P_e}$};
\node (bfg) [optimizer, right of=sec, xshift=2.0cm] {\textbf{L - BFGS}};
\node (tr) [second, below of=bfg, node distance=3cm,xshift=-1cm] {$S_w$,\:$P_e$};
\node[line width=2pt] (trb) [second, right of=tr, node distance=2cm] {\bfseries $JR$};
\node (aki) [io, below of=tr, node distance=3cm] {\textbf{AKR \& Gradient}};
\draw [arrow] (start) -- node[anchor=west] {$L$} (sec);
\draw [arrow] (sec) -- (bfg);
\draw [arrow] ([xshift=-1cm]bfg.south) -- node[anchor=west] {$L^{-1}$} (tr);
\draw [arrow] (tr) -- (aki);
\draw [arrow,line width=2pt,double] (trb) -- node[anchor=west] {$J+J_r$} ([xshift=1cm]bfg.south);
\draw [arrow,line width=2pt,double] ([xshift=2cm]aki.north) -- node[anchor=west] {$J$} (trb);
\end{tikzpicture}
\end{document}
答案2
这是你想要的吗?
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{startstop} = [rectangle, rounded corners,
minimum width=3cm,
minimum height=0.9cm,
text centered,
draw=black,
fill=white]
\tikzstyle{second} = [rectangle, rounded corners,
minimum width=1.5cm,
minimum height=0.7cm,
text centered,
draw=black,
fill=white]
\tikzstyle{optimizer} = [rectangle, rounded corners,
minimum width=4cm,
minimum height=1.2cm,
text centered,
draw=black,
fill=white]
\tikzstyle{true} = [rectangle, rounded corners,
minimum width=1.5cm,
minimum height=0.7cm,
text centered,
draw=black,
fill=white]
\tikzstyle{io} = [trapezium,
trapezium stretches=true, % A later addition
trapezium left angle=90,
trapezium right angle=90,
minimum width=5cm,
minimum height=1.5cm, text centered,
draw=black, fill=white]
\tikzstyle{process} = [rectangle,
minimum width=3cm,
minimum height=1cm,
text centered,
text width=3cm,
draw=black,
fill=orange!30]
\tikzstyle{decision} = [diamond,
minimum width=3cm,
minimum height=1cm,
text centered,
draw=black,
fill=green!30]
\tikzstyle{arrow} = [thin,->,>=stealth]
\begin{document}
\begin{tikzpicture}[node distance=2.0cm]
\node (start) [startstop] {Initial $S_{wo}$,\:$P_{eo}$};
\node (sec) [second, below of=start] {$m_{S_w}$,\:$m_{P_e}$};
\node (bfg) [optimizer, right of=sec, xshift=2.0cm] {\textbf{L - BFGS}};
\node (tr) [second, below of=bfg, node distance=3cm,xshift=-1cm,yshift=0cm] {$S_w$,\:$P_e$};
\node (trb) [second,draw=blue, right of=tr, node distance=2cm,yshift=-1cm] {\color{blue}$J_r$};
\node (trc) [second,draw=blue, right of=tr, node distance=2cm,yshift=1cm] {\color{blue}$J$};
\node (aki) [io, below of=bfg, node distance=6cm] {\textbf{AKR \& Gradient}};
\draw [arrow] (start) -- node[anchor=west] {$L$} (sec);
\draw [arrow] (sec) -- (bfg);
\draw [arrow] ([xshift=-1cm]bfg.south) -- node[anchor=west] {$L^{-1}$} (tr);
\draw [arrow] (tr) -- ([xshift=-1cm]aki.north);
\draw [arrow,blue] (trc) -- node[anchor=west] {$J+J_r$} ([xshift=1cm]bfg.south);
\draw [arrow,blue] (trb) -- node[anchor=west] {$J$} (trc.south);
\draw [arrow,blue] ([xshift=1cm]aki.north) -- node[anchor=west] {$J_r$} (trb);
\end{tikzpicture}
\end{document}