在 tikz 中让字体变成白色

在 tikz 中让字体变成白色

我正在 tikz 中创建流程图,并希望其中一个节点的字体为白色(即具有黑色背景的节点),但不知道该如何实现。此外,从输入到代理模型的箭头看起来很奇怪。我希望它直接向下然后向右转。

这是我的代码:

\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows,chains}

\tikzset{
  startstop/.style={
    rectangle, 
    rounded corners,
    minimum width=3cm, 
    minimum height=1cm,
    align=center, 
    draw=black, 
    fill=gray!30
        },
  process/.style={
    rectangle, 
    minimum width=3cm, 
    minimum height=1cm, 
    align=center, 
    draw=black, 
    fill=blue!30
    },
  decision/.style={
    rectangle, 
    minimum width=3cm, 
    minimum height=1cm, align=center, 
    draw=black, 
    fill=black
    },
  arrow/.style={thick,->,>=stealth},
  dec/.style={
    ellipse, 
    align=center, 
    draw=black, 
    fill=white
    },
}

\begin{figure}[http]
\center
%\resizebox{!}{.8\textheight}{% if required
\begin{tikzpicture}[
  start chain=going below,
  every join/.style={arrow},
  node distance=0.6cm
  ]
\node (start) [decision,on chain,join] {System: y=f(x)};
\node (inputs) [dec,left= 0.5in of start] {inputs: $x1,...,x_n$};
\node (end3)[dec,right= 0.5in of start] {$y$ output};
\draw[arrow] (start) -- node[auto] {} (end3);
\draw[arrow] (inputs) -- node[auto] {} (start);
\node (in1) [startstop,on chain] {Surrogate Model};
\draw [arrow] (inputs.south) |- +(20pt,0) |- (in1.west);
\draw [arrow] (in1.east) -- +(20pt,0) -| (end3.south);
\end{tikzpicture}
%}
\caption{}
\end{figure} 

答案1

只需添加text=white定义decision

  decision/.style={
    rectangle,
    minimum width=3cm,
    minimum height=1cm, align=center,
    draw=black,
    fill=black,
    text=white% <--- added
    },

升级:我想,你喜欢有箭头的东西,如下图所示:

在此处输入图片描述

对于这张图片,我只删除了 MWE 最后一行多余的部分-- +(20pt,0)

\draw [arrow]  (in1.east) -| (end3.south);

我也简单把箭头的定义一下:

arrow/.style={thick,-stealth},

相关内容