穿过方框的弯曲线条(tikz)

穿过方框的弯曲线条(tikz)

感谢您的帮助,我能够使用 TikZ 创建一些基本的东西。但是,在创建没有所有直线的较大图像时,我遇到了麻烦。我不知道如何通过 BNP 在框 EIB 和 Parter Re 之间画线。我也在努力让文本好看,但这不是我的主要问题。如果有人能提供一些建议,那就太好了!将不胜感激

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows, positioning, quotes}

\begin{document}
\begin{tikzpicture}[
    node distance=10mm and 29mm,
box/.style = {draw, minimum height=35mm, minimum width=20mm, align=center},
sy+/.style = {yshift= 2mm}, 
sy-/.style = {yshift=-2mm},
every edge quotes/.style = {align=center}
                        ]
\node (n1) [box]             {\textbf{Investor}};                        
\node (n2) [box,right=of n1] {\textbf{EIB}};
\node (n3) [box,right=of n2] {\textbf{BNP}};
\node (n4) [box,below=of n3,minimum height=20mm] {\textbf{Partner Re}};
%
\draw[very thick,->, transform canvas={yshift=2em}]  
    ([sy+] n1.east) to [above,"Issue price  \\ \hspace{2cm} \\ \hspace{2cm}"] ([sy+] n2.west);
\draw[very thick, dashed,->,transform canvas={yshift=-2em}]  
    ([sy-] n2.west) to [below," \hspace{2cm} \\ \hspace{2cm} \\ Notional $\times$ realized mortality rate"] ([sy-] n1.east);

    \draw[very thick,->, transform canvas={yshift=2em}]  
    ([sy+] n2.east) to [above,"\footnotesize Interest rate swap  \\ \hspace{2cm} \\ \hspace{2cm}"] ([sy+] n3.west);
\draw[very thick, dashed,->,transform canvas={yshift=2em}]  
    ([sy-] n3.west) -- ([sy-] n2.east);
    \end{tikzpicture}    
\end{document}

在此处输入图片描述

在此处输入图片描述

答案1

首先,如果给节点赋予好的名字,就可以使生活变得更轻松,例如n1=> invn2=> eibn3=> bnpn4=> pre

然后,从 eib 到 bnp 再到 pre 的线路可以用以下方式完成:

\draw[->] ([yshift=-1cm]eib.east) -- ([shift={(4mm,-1cm)}] bnp.center) -- ([xshift=4mm]pre.north);

答案2

我改变了一些小事情:

  • 通过助记符技术重命名节点。
  • 已删除transform canvas。(目的是什么?)
  • 删除了quotes库。(没什么坏处,但是有什么好处呢?)

可以通过在绘图命令中使用-|而不是 来实现“弯曲”的线条,如下所示:--

\draw[<-] ([sY-] eib.east) -| ([sx-]pre.north);
\draw[->] ([sy-] eib.east) -| ([sx+]pre.north);

在此处输入图片描述

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows, positioning}
\begin{document}
\begin{tikzpicture}%
   [node distance=10mm and 29mm,
    >=stealth,
    box/.style = {draw, minimum height=35mm, minimum width=20mm, align=center},
    sY+/.style = {yshift= 1cm}, 
    sy+/.style = {yshift= 0.8cm}, 
    sY-/.style = {yshift=-1cm},
    sy-/.style = {yshift=-0.8cm},
    sx+/.style = {xshift=3mm},
    sx-/.style = {xshift=-3mm},
   ]
\node (inv) [box]              {\textbf{Investor}};                        
\node (eib) [box,right=of inv] {\textbf{EIB}};
\node (bnp) [box,right=of eib] {\textbf{BNP}};
\node (pre) [box,below=of bnp,minimum height=20mm] {\textbf{Partner Re}};

\draw[very thick,->]  
   ([sY+] inv.east) -- node[above,yshift=8mm]{Issue price} ([sY+] eib.west);
\draw[very thick,<-,dashed]  
   ([sY-] inv.east) -- node[below,yshift=-8mm]{Notional $\times$ realized mortality rate} ([sY-] eib.west);

\draw[very thick,->]  
   ([sY+] eib.east) -- node[above,yshift=8mm]{\footnotesize Interest rate swap} ([sY+] bnp.west);
\draw[very thick,<-,dashed]
   ([sy+] eib.east) -- ([sy+] bnp.west);

\draw[<-] ([sY-] eib.east) -| ([sx-]pre.north);
\draw[->] ([sy-] eib.east) -| ([sx+]pre.north);
\end{tikzpicture}    
\end{document}

相关内容