你能帮我解决这个问题吗?“卡尔曼滤波器”是下面节点的标签,我想要像红色箭头一样的箭头。提前谢谢您。
\begin{tikzpicture}
\node[draw,fill=white,ellipse,minimum height=5cm,minimum width=5cm,text width = 2cm,align=center,label=above:\textbf{State-space model}] (A)
{Transition \\
abc abc \\
$ \downarrow $ \\
Measurement\\
$y_t = \hat{t}$ };
\node[xshift=8cm,draw,fill=white,ellipse,minimum height=5cm,minimum width=5cm,text width=2cm,align=center,label=above:\textbf{Estimated data Empirical data}] (B)
{$ y \rightarrow \emptyset $ \\
\vspace{5mm}
$ y_{t / t-1} \rightarrow y_t $};
\node[xshift=4cm,yshift=-5cm,draw,fill=white,ellipse,text width=4cm,align=center,label=above:\textbf{Kalman filter}] (C)
{$ v_t = y_t - y_{t,t-1} $};
\node[xshift=4cm,yshift=-7.5cm,draw,fill=white,rectangle,minimum height=1.2cm,text width=1.5cm,align=center] (D)
{$ y_t $};
\path[->] (A) edge (C);
\draw [->] (B) to (C);
\draw [->] (C) to (D);
\end{tikzpicture}
答案1
用 为标签节点命名label={[name=kalman]above:\textbf{Kalman filter}}
,并绘制到kalman
而不是C
。
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\node[draw,fill=white,ellipse,minimum height=5cm,minimum width=5cm,text width = 2cm,align=center,label=above:\textbf{State-space model}] (A)
{Transition \\
abc abc \\
$ \downarrow $ \\
Measurement\\
$y_t = \hat{t}$ };
\node[xshift=8cm,draw,fill=white,ellipse,minimum height=5cm,minimum width=5cm,text width=2cm,align=center,label=above:\textbf{Estimated data Empirical data}] (B)
{$ y \rightarrow \emptyset $ \\
\vspace{5mm}
$ y_{t / t-1} \rightarrow y_t $};
\node[xshift=4cm,yshift=-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=-7.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}
\end{document}
答案2
更新答案:出于某种原因,你似乎不喜欢Torbjørn 的出色解决方案,因此这里有一个替代方案:使用 Torbjørn 的巧妙解决方案以及fit
。这样做的好处是箭头指向节点C
,而不是标签,并摆脱了我之前的提议(见下文)的一大缺点,即必须手动调整距离。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.geometric,fit}
\begin{document}
\begin{tikzpicture}
\node[draw,fill=white,ellipse,minimum height=5cm,minimum width=5cm,text width = 2cm,align=center,label=above:\textbf{State-space model}] (A)
{Transition \\
abc abc \\
$ \downarrow $ \\
Measurement\\
$y_t = \hat{t}$ };
\node[xshift=8cm,draw,fill=white,ellipse,minimum height=5cm,minimum width=5cm,text width=2cm,align=center,label=above:\textbf{Estimated data Empirical data}] (B)
{$ y \rightarrow \emptyset $ \\[5mm]
$ y_{t / t-1} \rightarrow y_t $};
\node[xshift=4cm,yshift=-5cm,draw,fill=white,ellipse,text width=4cm,align=center,
label={[name=kalman,font=\bfseries]above:Kalman filter}] (C)
{$ v_t = y_t - y_{t,t-1} $};
\node[xshift=4cm,yshift=-7.5cm,draw,fill=white,rectangle,minimum height=1.2cm,text width=1.5cm,align=center] (D)
{$ y_t $};
\node[fit=(C) (kalman)] (F){};
\draw[->] (A) to (F);
\draw[->] (B) to (F);
\draw [->] (C) to (D);
\end{tikzpicture}
\end{document}
原始提案: 使用shorten
。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\node[draw,fill=white,ellipse,minimum height=5cm,minimum width=5cm,text width = 2cm,align=center,label=above:\textbf{State-space model}] (A)
{Transition \\
abc abc \\
$ \downarrow $ \\
Measurement\\
$y_t = \hat{t}$ };
\node[xshift=8cm,draw,fill=white,ellipse,minimum height=5cm,minimum width=5cm,text width=2cm,align=center,label=above:\textbf{Estimated data Empirical data}] (B)
{$ y \rightarrow \emptyset $ \\[5mm]
$ y_{t / t-1} \rightarrow y_t $};
\node[xshift=4cm,yshift=-5cm,draw,fill=white,ellipse,text width=4cm,align=center,label=above:\textbf{Kalman filter}] (C)
{$ v_t = y_t - y_{t,t-1} $};
\node[xshift=4cm,yshift=-7.5cm,draw,fill=white,rectangle,minimum height=1.2cm,text width=1.5cm,align=center] (D)
{$ y_t $};
\draw[->,shorten >=6mm] (A) edge (C);
\draw[->,shorten >=6mm] (B) to (C);
\draw [->] (C) to (D);
\end{tikzpicture}
\end{document}
这种解决方案的最大缺点是您必须手动输入6mm
,略微的优点是箭头指向C
节点的中心,而不是标签的中心。