在节点 Tikz 上画一条线

在节点 Tikz 上画一条线

有人能帮我画一条红线吗 --- 就像照片里的那样?提前谢谢了。

\begin{tikzpicture}
\node[draw,fill=white,ellipse,minimum height=4cm,minimum width=7cm,text width = 5cm,align=center,label=above:\textbf{qStqsfate-spqsface mqsdfodel}] (A)
  {Tranqsdfqsiqsftion \\
  $ \tilde{y}_{t/t-1} = g \big( \tilde{y}_{t-1} ; u_t ; \omega_t \big) $ \\
  $ \downarrow $ \\
  Measurement\\
  $ \tilde{z}_{t/t-1} = f \big( \tilde{y}_{t-1} ; u_t ; \omega_t \big) $  };
\node[xshift=8cm,draw,fill=white,ellipse,minimum height=4cm,minimum width=7cm,text width=5cm,align=center,label=above:\textbf{Estqsdfqsimateqsdfd daqsdfqsdta \; \; \; Empiriqsdfqsdfcal daqsdfqdsfta}] (B)
  {$ \; \; \tilde{y}_{t} \rightarrow \emptyset $ \\
  \vspace{5mm}
  $  \tilde{z}_{t/t-1} \rightarrow z_t $};
\node[xshift=4cm,yshift=-4.5cm,draw,fill=white,ellipse,text width=4cm,align=center,label={[name=kalman]above:\textbf{Kqsdfqalmqsdfqan fqsdfqsdiltqsdfqser}}] (C)
  {$ v_t = y_t - y_{t,t-1} $};
\node[xshift=4cm,yshift=-6.5cm,draw,fill=white,rectangle,minimum height=1.2cm,text width=1.5cm,align=center] (D)
  {$ y_t $};  

\draw [->] (A) to (kalman);
\draw [->] (B) to (kalman);
\draw [->] (C) to (D);

\end{tikzpicture}

enter image description here

答案1

这是你想要的?

有问题的节点已经名为(B),因此您只需从 到 画一条线即可(B.south)(B.north)要稍微扩展这些坐标,请yshift在坐标内使用,如下所示:([yshift=-0.5cm]B.south)([yshift=0.5cm]B.north)

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\node[draw,fill=white,ellipse,minimum height=4cm,minimum width=7cm,text width = 5cm,align=center,label=above:\textbf{State-space model}] (A)
  {Transition \\
  $ \tilde{y}_{t/t-1} = g \big( \tilde{y}_{t-1} ; u_t ; \omega_t \big) $ \\
  $ \downarrow $ \\
  Measurement\\
  $ \tilde{z}_{t/t-1} = f \big( \tilde{y}_{t-1} ; u_t ; \omega_t \big) $  };
\node[xshift=8cm,draw,fill=white,ellipse,minimum height=4cm,minimum width=7cm,text width=5cm,align=center,label=above:\textbf{Estimated data \; \; \; Empirical data}] (B)
  {$ \; \; \tilde{y}_{t} \rightarrow \emptyset $ \\
  \vspace{5mm}
  $  \tilde{z}_{t/t-1} \rightarrow z_t $};
\node[xshift=4cm,yshift=-4.5cm,draw,fill=white,ellipse,text width=4cm,align=center,label={[name=kalman]above:\textbf{Kalman filter}}] (C)
  {$ v_t = y_t - y_{t,t-1} $};
\node[xshift=4cm,yshift=-6.5cm,draw,fill=white,rectangle,minimum height=1.2cm,text width=1.5cm,align=center] (D)
  {$ y_t $};  

\draw [red,dashed] ([yshift=-0.5cm]B.south)--([yshift=0.5cm]B.north); %<---- added

\draw [->] (A) to (kalman);
\draw [->] (B) to (kalman);
\draw [->] (C) to (D);

\end{tikzpicture}
\end{document}

答案2

米洛答案,但是要努力使图像代码简洁而简短:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{calc, positioning, shapes}
\usepackage{amsmath, amssymb}

\begin{document}
    \begin{tikzpicture}[
node distance = 8mm and 4mm,
E/.style args = {#1/#2}{ellipse, draw, minimum height=#1,
            text width=#2, align=center},
   E/.default = 4cm/5cm
                        ]
\node[E, label=above:\textbf{State-space model}] (A)
        {Transition \\
        $\tilde{y}_{t/t-1} = g \big( \tilde{y}_{t-1} ; u_t ; \omega_t \big) $ \\
        $ \downarrow $ \\
        Measurement\\
        $ \tilde{z}_{t/t-1} = f \big( \tilde{y}_{t-1} ; u_t ; \omega_t \big) $
        };
\node[E, label=above:\textbf{Estimated data \quad Empirical data},
      right=of A] (B)
        {$\begin{aligned}
            \tilde{y}_{t}       & \rightarrow \emptyset\\[5mm]
            \tilde{z}_{t/t-1}   & \rightarrow z_{t\hphantom{/t-1}} % <---
         \end{aligned}$
         };
\node[E=2em/3cm,
      label={[name=kalman]above:\textbf{Kalman filter}},
      below=of $(A.south)!0.5!(B.south)$ ] (C)
        {$ v_t = y_t - y_{t,t-1} $};
\node[draw, minimum height=1.2cm, minimum width=1.5cm,
      below=of C] (D)
        {$ y_t $};
%
\draw[->]   (A) edge (kalman)
            (B) edge (kalman)
            (C)  to  (D);
% line through ellipse B
\draw[thick, dashed, red]   ([yshift=3mm] B.north) -- ([yshift=-3mm] B.south);
\end{tikzpicture}
\end{document}
  • 用于节点定位的 tikzpositioning and计算
  • 为椭圆定义通用样式
  • eliipse“B”中的方程使用aligned包中定义的环境amsmath

笔记:请始终将代码片段范围调整到完整但较小的文档。如果我们看到包含有关您的图像的(仅相关的)信息的序言,则更容易为您提供帮助。

enter image description here

相关内容