我想要画一张这样的图:
我尝试过并得到:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, shapes.geometric}
\begin{document}
\begin{tikzpicture}[node distance=10pt]
\node[draw, rounded corners, align=center, fill=blue!20, fill opacity=0.6, minimum width=2cm,minimum height=1cm] (start) {\textbf{Firstly}\\$A$};
\node[draw, below=of start, align=center, fill=blue!40, fill opacity=0.7, minimum width=3cm,minimum height=1cm] (step 1) {\textbf{Secondly}\\$B$};
\node[draw, below=of step 1, align=center, fill=blue!40, fill opacity=0.7, minimum width=3cm,minimum height=1cm] (step 2) {\textbf{data}\\$A+B$};
\node[draw, ellipse, right=30pt of step 2, align=center, fill=yellow!40, fill opacity=0.7] (step x1) {e};
\node[draw, below=of step 2, align=center, fill=blue!40, fill opacity=0.7, minimum width=3cm,minimum height=1cm] (step 3) {\textbf{Finally}};
\node[draw, ellipse, right=30pt of step 3, align=center, fill=yellow!40, fill opacity=0.7, minimum width=2cm,minimum height=1cm] (step x2) {\textbf{e}};
\node[draw, rounded corners, fill=blue!40, fill opacity=0.7, below=20pt of step 3] (end) {End};
\draw[->] (start) -- (step 1);
\draw[->] (step 1) -- (step 2);
\draw[->] (step 2) -- (step 3);
\draw[->] (step 3) -- (end);
\draw[->] (step 1) -| (step x1);
\draw[->] (step x1) -- (step 2);
\draw[->] (step 2) -| (step x2);
\draw[->] (step x2) -- (step 3);
\end{tikzpicture}
\end{document}
答案1
像这样?
通过使用tikz
库arrows.meta
、、、、calc
和
chains
:ext.paths.ortho
positioning
shapes.geometric
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
calc, chains,
ext.paths.ortho, % defined in the tikz-ext package
positioning,
shapes.geometric}
\begin{document}
\begin{tikzpicture}[
node distance = 8mm and 6mm,
start chain = going below,
arr/.style = {-Stealth},
M/.style = {draw, fill=blue!40, minimum height=1cm, text width=1.2cm, align=center},
N/.style args = {#1/#2}{draw, fill=#1, minimum height=1cm, text width=#2, align=center,
on chain, join=by arr},
N/.default = blue!40/3cm,
E/.style = {ellipse, draw, fill=yellow!40, inner xsep= 0pt, minimum width=1cm, align=center}
]
\node[N=blue!20/2cm, rounded corners] (start) {\textbf{Firstly}\\$A$};
\node[N] (step 1) {\textbf{Secondly}\\ $B$};
\node[N] (step 2) {\textbf{data}\\ $A+B$};
\node[N] (step 3) {\textbf{Finally}};
%
\node[E, right=of $(step 1.east)!0.5!(step 2.east)$] (step e) {e};
\node[E, right=of $(step 2.east)!0.5!(step 3.east)$] (step f) {f};
%
\node[M, below right=8mm and 0mm of step 3.south west] (c) {$C$};
\node[M, below left=8mm and 0mm of step 3.south east] (d) {$D$};
% arrows not considered in join macro
\draw[arr] (step 1.east) to[bend left] (step e);
\draw[arr] (step e) to[bend left] ([yshift=+2mm] step 2.east);
\draw[arr] ([yshift=-2mm] step 2.east) to[bend left] (step f);
\draw[arr] (step f) to[bend left] (step 3.east);
%
\draw[arr] (step 3) |-| (c); % <---
\draw[arr] (step 3) |-| (d); % <---
\end{tikzpicture}
\end{document}