定义流程图 tikz 的样式

定义流程图 tikz 的样式

我一直在尝试定义样式以在 TikZ 包中制作出好的框图,但我不太擅长,你能用蓝色、青色和绿色的组合制作一个吗?我需要描述解决一对微分方程的过程。我在序言中有这个:

\usepackage{tikz}
\usetikzlibrary{%
    decorations.pathreplacing,%
    decorations.pathmorphing,%
    arrows,
    shapes,
    shapes.geometric
    }
    \tikzstyle{load}   = [ultra thick,-latex]
    \tikzstyle{stress} = [-latex]
    \tikzstyle{dim}    = [latex-latex]
    \tikzstyle{axis}   = [-latex,black!55]
 \tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
 \tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
 \tikzstyle{process} = [rectangle, minimum width=4cm, minimum height=1cm, text centered, text width=4cm, draw=black, fill=orange!30]
 \tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text width=3cm, text centered, draw=black, fill=green!30]
 \tikzstyle{arrow} = [thick,->,>=stealth]

我制作的流程图之一如下

\begin{center}
\begin{tikzpicture}[node distance=3cm]
\node (start) [startstop] {Dada una EDO de $1^{er}$ orden};
\node (dec1) [decision, below of=start,yshift=-1cm] {¿Es de la forma $\frac{dy}{dx}=f(x)\cdot g(y)$?};
\node (pro1a) [process, right of=dec1, xshift=2cm] {Emplee una sustitución $u$, tal que $\frac{du}{dx}=G(u)F(x)$ y siga el caso como si:};
\node (pro1b) [process, below of=dec1,yshift=-1cm] {Transforme en $\frac{dy}{g(y)}=f(x)dx$};
\node (pro2) [process, below of=pro1b] {Integre};
\node (end) [startstop, below of=pro2] {$H(y)=T(x)+C$, Solución general};
\draw [arrow] (start) -- (dec1);
\draw [arrow] (dec1) -- node[anchor=east] {sí} (pro1b);
\draw [arrow] (dec1) -- node[anchor=south] {no} (pro1a);
\draw [arrow] (pro1a) |- (pro1b);
\draw [arrow] (pro1b) -- (pro2);
\draw [arrow] (pro2) -- (end);
\end{tikzpicture}
\end{center}

我得到了这个: 我的流程图

我一直在观察,这些风格引起了我的注意 样式 1 样式 2 风格 3

答案1

以下是三种不同节点集样式的定义,以获取您发布的图像的外观:

在此处输入图片描述

代码:

\documentclass[varwidth]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{%
    decorations.pathreplacing,%
    decorations.pathmorphing,%
    arrows,
    arrows.meta,
    positioning,
    shapes,
    shadows,
    shapes.geometric
    }

\definecolor{myblue1}{RGB}{0,157,209}
\definecolor{myblue2}{RGB}{161,224,255}
\definecolor{myblue3}{RGB}{216,229,245}
\definecolor{myblue4}{RGB}{0,149,229}

\tikzset{
  startend1/.style={
    rectangle, 
    rounded corners=15pt, 
    text width=2cm, 
    minimum height=1cm,
    align=center, 
    line width=2pt,
    draw=white,
    font=\color{white}\sffamily, 
    fill=myblue1,
    drop shadow
  },  
 data1/.style={
   trapezium, 
   trapezium left angle=70, 
   trapezium right angle=110, 
   text width=1.5cm, 
   inner ysep=17pt,
   align=center, 
   line width=2pt,
   draw=white,
   font=\color{black}\sffamily, 
   top color=myblue2,
   bottom color=myblue2!20,
   drop shadow
  },  
  process1/.style={
    rounded corners,
    text width=2.6cm, 
    minimum height=1.5cm, 
    align=center, 
    font=\color{white}\sffamily, 
    line width=2pt,
    draw=white, 
    top color=myblue1,
    bottom color=myblue1!30,
    drop shadow
  },  
  decision1/.style={
    diamond, 
    text width=1.5cm, 
    align=center, 
    font=\color{white}\sffamily, 
    line width=2pt,
    draw=white, 
    fill=myblue1,
    drop shadow
  },  
  arrow1/.style={
    {Square[]}->,
    myblue1,
    >=stealth
  },  
} 

\tikzset{
  startend2/.style={
    rectangle, 
    rounded corners=15pt, 
    text width=2cm, 
    minimum height=1cm,
    align=center, 
    line width=1pt,
   draw=myblue1!70!black, 
    font=\color{white}\sffamily, 
    fill=myblue1,
  },  
 data2/.style={
   trapezium, 
   trapezium left angle=70, 
   trapezium right angle=110, 
   text width=1.5cm, 
   inner ysep=17pt,
   align=center, 
   line width=1pt,
   draw=myblue1!70!black, 
   font=\color{black}\sffamily, 
   fill=myblue1,
  },  
  process2/.style={
    rounded corners,
    text width=2.6cm, 
    minimum height=1.5cm, 
    align=center, 
    font=\color{white}\sffamily, 
    draw=myblue1!70!black,
    line width=1pt, 
    fill=myblue1,
  },  
  decision2/.style={
    diamond, 
    text width=1.5cm, 
    align=center, 
    font=\color{white}\sffamily, 
    line width=1pt,
    draw=myblue1!70!black, 
    fill=myblue1,
  },  
  arrow2/.style={
     ->,
    myblue1,
    >=stealth
  },  
} 

\tikzset{
  startend3/.style={
    rectangle, 
    rounded corners=15pt, 
    text width=2cm, 
    minimum height=1cm,
    align=center, 
    line width=2pt,
    font=\color{myblue1}\sffamily, 
    fill=myblue3,
  },  
 data3/.style={
   trapezium, 
   trapezium left angle=70, 
   trapezium right angle=110, 
   text width=1.5cm, 
   inner ysep=17pt,
   align=center,
   draw=myblue1, 
   font=\color{myblue1}\sffamily, 
   fill=white
  },  
  process3/.style={
    text width=2.6cm, 
    minimum height=1.5cm, 
    align=center, 
    font=\color{white}\sffamily, 
    fill=myblue4,
  },  
  decision3/.style={
    diamond, 
    text width=1.5cm, 
    align=center, 
    font=\color{myblue1}\sffamily, 
    fill=myblue3,
  },  
  arrow3/.style={
    ->,
    myblue1,
    >=stealth
  },  
} 

\begin{document}

\begin{tikzpicture}[node distance=1.5cm and 2cm]
\node[startend1] 
  (start) 
  {start};
\node[decision1,right=of start] 
  (dec) 
  {dec1};
\node[process1,right=of dec] 
  (pro) 
  {process};
\node[data1,below=of dec] 
  (data) 
  {data};
\coordinate[below=of data] (aux);  
\node[startend1] 
  (end) 
  at (pro|-aux)
  {end};

\begin{scope}[arrow1]
\draw
  (start) --  (dec);
\draw
  (dec) --  node[fill=white] {yes} (pro);
\draw
  (dec) --  node[fill=white] {no} (data);
\draw
  (pro) |- (data);
\draw
  (data) |- (end);
\end{scope}  
\end{tikzpicture}

\begin{tikzpicture}[node distance=1.5cm and 2cm]
\node[startend2] 
  (start) 
  {start};
\node[decision2,right=of start] 
  (dec) 
  {dec2};
\node[process2,right=of dec] 
  (pro) 
  {process};
\node[data2,below=of dec] 
  (data) 
  {data};
\coordinate[below=of data] (aux);  
\node[startend2] 
  (end) 
  at (pro|-aux)
  {end};

\begin{scope}[arrow2]
\draw
  (start) --  (dec);
\draw
  (dec) --  node[fill=white] {yes} (pro);
\draw
  (dec) --  node[fill=white] {no} (data);
\draw
  (pro) |- (data);
\draw
  (data) |- (end);
\end{scope}  
\end{tikzpicture}

\begin{tikzpicture}[node distance=1.5cm and 2cm]
\node[startend3] 
  (start) 
  {start};
\node[decision3,right=of start] 
  (dec) 
  {dec3};
\node[process3,right=of dec] 
  (pro) 
  {process};
\node[data3,below=of dec] 
  (data) 
  {data};
\coordinate[below=of data] (aux);  
\node[startend3] 
  (end) 
  at (pro|-aux)
  {end};

\begin{scope}[arrow3]
\draw
  (start) --  (dec);
\draw
  (dec) --  node[fill=white] {yes} (pro);
\draw
  (dec) --  node[fill=white] {no} (data);
\draw
  (pro) |- (data);
\draw
  (data) |- (end);
\end{scope}  
\end{tikzpicture}

\end{document}

这是适合样式 1 的实际图表:

\documentclass[varwidth,border=3pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{%
    decorations.pathreplacing,%
    decorations.pathmorphing,%
    arrows,
    arrows.meta,
    positioning,
    shapes,
    shadows,
    shapes.geometric
    }

\definecolor{myblue1}{RGB}{0,157,209}
\definecolor{myblue2}{RGB}{161,224,255}
\definecolor{myblue3}{RGB}{216,229,245}
\definecolor{myblue4}{RGB}{0,149,229}

\tikzset{
  startend1/.style={
    rectangle, 
    rounded corners=15pt, 
    text width=3cm, 
    minimum height=1cm,
    align=center, 
    line width=2pt,
    draw=white,
    font=\color{white}\sffamily, 
    fill=myblue1,
    drop shadow
  },  
 data1/.style={
   trapezium, 
   trapezium left angle=70, 
   trapezium right angle=110, 
   text width=1.5cm, 
   inner ysep=17pt,
   align=center, 
   line width=2pt,
   draw=white,
   font=\color{black}\sffamily, 
   top color=myblue2,
   bottom color=myblue2!20,
   drop shadow
  },  
  process1/.style={
    rounded corners,
    text width=4cm, 
    minimum height=1.5cm, 
    align=center, 
    font=\color{white}\sffamily, 
    line width=2pt,
    draw=white, 
    top color=myblue1,
    bottom color=myblue1!30,
    drop shadow
  },  
  decision1/.style={
    diamond, 
    text width=3cm, 
    align=center, 
    font=\color{white}\sffamily, 
    line width=2pt,
    draw=white, 
    fill=myblue1,
    drop shadow
  },  
  arrow1/.style={
    {Square[]}->,
    myblue1,
    >=stealth
  },  
} 

\begin{document}

\begin{tikzpicture}[node distance=1cm]
\node[startend1] 
  (start)  
  {Dada una EDO de $1^{er}$ orden};
\node[decision1,below=of start] 
  (dec1)  
  {¿Es de la forma $\frac{dy}{dx}=f(x)\cdot g(y)$?};
\node[process1, right=of dec1] 
  (pro1a)  
  {Emplee una sustitución $u$, tal que $\frac{du}{dx}=G(u)F(x)$ y siga el caso como si:};
\node[process1, below= of dec1] 
  (pro1b)  
  {Transforme en $\frac{dy}{g(y)}=f(x)dx$};
\node[process1, below=of pro1b] 
  (pro2)  
  {Integre};
\node[startend1, below=of pro2] 
  (end)  
  {$H(y)=T(x)+C$, Solución general};

\draw[arrow1] 
  (start) -- (dec1);
\draw[arrow1] 
  (dec1) -- node[anchor=east] {sí} (pro1b);
\draw[arrow1] 
  (dec1) -- node[anchor=south] {no} (pro1a);
\draw[arrow1] 
  (pro1a) |- (pro1b);
\draw[arrow1] 
  (pro1b) -- (pro2);
\draw[arrow1] 
  (pro2) -- (end);
\end{tikzpicture}

\end{document}

在此处输入图片描述

评论

  • shadows库用于为节点形状添加阴影。

  • arrows.meta库用于使用 来生成箭头{Square[]}->

  • 使用top colorbottom color键,使用垂直阴影对节点进行着色。

  • 借助该库,旧的和不适当的of=语法已被取代。=ofpositioning

  • 旧的\tikzstyle已经被更新、更便捷的所取代\tikzset

相关内容