如何让箭头更加清晰可辨

如何让箭头更加清晰可辨

我想知道是否有办法可以偏移箭头的入口(一些在中心左侧,一些在中心右侧)或者使箭头的头部在左下方?我也是色盲,所以我尝试使用不同的图案(点线与虚线)来区分左下角的箭头,但没有成功。所以如果有选项可以更改箭头的粗细,那就太好了。

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath,amssymb}
\usepackage{amsthm}
\usepackage{forest}
\usepackage{tikz}
\usepackage{pdflscape}
\pagenumbering{gobble}

\usetikzlibrary{positioning,calc,arrows.meta}%arrows is deprecated

\begin{document}

\begin{landscape}

\begin{figure}[htbp]
    \centering
    \begin{tikzpicture}[->,>=Stealth,auto,scale=0.6,
        thick,main node/.style={draw, rectangle, align=center}]

\node[main node,text width=2cm] (1) at (0,14)    {$\text{shared\_info}$};
\node[main node,text width=2cm, anchor=north west] (2) at(1.north east) {$\text{outer\_names}$};
\node[main node,text width=2cm, anchor=south west] (3) at(2.north east) {$\text{all\_names}$};
\node[main node,text width=2cm, anchor=north west] (4) at(3.north east) {$\text{msgs}$};


\node[main node,text width=2cm] (5) at (-8,0)    {$\text{shared\_info}$};
\node[main node,text width=2cm, anchor=north west] (6) at(5.north east) {$\text{assigned\_in}$};
\node[main node,text width=2cm, anchor=south west] (7) at(6.north east) {$\text{all\_names}$};
\node[main node,text width=2cm, anchor=north west] (8) at(7.north east) {$\text{msgs}$};


\node[main node,text width=2cm] (9) at (8,0)    {$\text{shared\_info}$};
\node[main node,text width=2cm, anchor=north west] (10) at(9.north east) {$\text{assigned\_in}$};
\node[main node,text width=2cm, anchor=south west] (11) at(10.north east) {$\text{all\_names}$};
\node[main node,text width=2cm, anchor=north west] (12) at(11.north east) {$\text{msgs}$};
\node[main node,text width=2cm, anchor=north west] (13) at(12.north east) {$\text{assigned\_out}$};

\draw[black] (1.south) to[out=-90, in=90,looseness=0.8] (5.north);
\draw[black] (1.south) to[out=-90, in=90,looseness=0.8] (9.north);

\draw[black] (2.south) to[out=-90, in=90,looseness=0.8] (10.north);


\draw[black] (7.north) to[out=90, in=-90,looseness=0.8] (3.south);

\draw[black] (8.north) to[out=90, in=-90,looseness=0.8] (4.south);

\draw[black] (11.north) to[out=90, in=-90,looseness=0.8] (3.south);

\draw[black] (12.north) to[out=90, in=-90,looseness=0.8] (4.south);

\draw[black] (13.north) to[out=90, in=90,looseness=0.8] (6.north);
\draw[black] (13.north) to[out=90, in=90,looseness=0.8] (10.north);

\draw[red] (10.south) to[out=-90, in=-90,looseness=0.8] (13.south);

\draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (6.south);
\draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (7.south);
\draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (8.south);

\draw[blue,dotted] (6.south) to[out=-90, in=-90,looseness=1] (8.south);

\draw[green!50!black,dotted] (7.south) to[out=-90, in=-90,looseness=1] (8.south);
\draw[green!50!black,dotted] (7.south) to[out=-90, in=-90,looseness=1] (6.south);


\draw[red,dotted] (2.north) to[out=90, in=90,looseness=1] (4.north);

\end{tikzpicture} 


\end{figure}

\end{landscape}


\end{document}

在此处输入图片描述

答案1

east请记住,除了经典的、westnorth之外,您还可以获得节点的出口点或入口点,south它们相当于090°180°270°它们在角度处的组合45°,您可以在节点与从节点中心以您指示的角度 发出的射线的交点之间获得节点周边的点node_name.angle。您可以查看 PGF 手册的第 67 节。

在示例中,我使用这些点来找到箭头要显示的更好的着陆点,我还匹配了箭头的输入和输出值,我添加了一些样式管理实践,并在箭头中使用了节点,以免迷失方向。很抱歉删除了您原始代码的部分内容,但它应该坚持成为最小工作示例

结果:

在此处输入图片描述

梅威瑟:

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta,positioning}
\usepackage{amsmath}
\begin{document}
    \begin{tikzpicture}[
        >=Stealth,
        thick,
        auto,
        NodeBlack/.style={
            draw,
            rectangle,
            align=center,
            text width=2cm
        },
        NodeFancy/.style={
            draw=black,
            rectangle,
            rounded corners,
            align=center,
            text width=2cm,
            text opacity=1,
            text=green!50!black,
            fill=green!50!blue,
            fill opacity=0.4
        },
        ArrowBlack/.style={black,->},
        ArrowRed/.style={red,dash dot,->},
        ArrowGreen/.style={green!50!black, very thick,dotted,->}
    ]
    % Nodes
    \node[NodeBlack] (1) at (0,7)    {$\text{shared\_info}$};
    \node[NodeBlack, anchor=north west] (2) at(1.north east) {$\text{outer\_names}$};
    \node[NodeBlack, anchor=south west] (3) at(2.north east) {$\text{all\_names}$};
    \node[NodeBlack, anchor=north west] (4) at(3.north east) {$\text{msgs}$};
    \node[NodeBlack] (5) at (-5,0)    {$\text{shared\_info}$};
    \node[NodeBlack, anchor=north west] (6) at(5.north east) {$\text{assigned\_in}$};
    \node[NodeBlack, anchor=south west] (7) at(6.north east) {$\text{all\_names}$};
    \node[NodeBlack, anchor=north west] (8) at(7.north east) {$\text{msgs}$};
    \node[NodeFancy] (9) at (5,0)    {$\text{shared\_info}$};
    \node[NodeBlack, anchor=north west] (10) at(9.north east) {$\text{assigned\_in}$};
    \node[NodeBlack, anchor=south west] (11) at(10.north east) {$\text{all\_names}$};
    \node[NodeBlack, anchor=north west] (12) at(11.north east) {$\text{msgs}$};
    \node[NodeFancy, anchor=north west] (13) at(12.north east) {$\text{assigned\_out}$};
    % Arrows        
    \draw[ArrowBlack] (1.-105) to[out=-105, in=90,looseness=0.8]node[pos=0.7,sloped]{1} (5.90);
    \draw[ArrowBlack] (1.-75) to[out=-75, in=90,looseness=0.8]node[pos=0.7,sloped]{2} (9.90);
    \draw[ArrowBlack] (2.-90) to[out=-90, in=105,looseness=0.8]node[pos=0.7,sloped]{3} (10.105);
    \draw[ArrowBlack] (7.north) to[out=90, in=-105,looseness=0.8]node[pos=0.7,sloped]{4} (3.-105);
    \draw[ArrowBlack] (8.north) to[out=90, in=-105,looseness=0.8]node[pos=0.7,sloped]{5} (4.-105);
    \draw[ArrowBlack] (11.north) to[out=90, in=-75,looseness=0.8]node[pos=0.7,sloped]{6} (3.-75);
    \draw[ArrowBlack] (12.north) to[out=90, in=-75,looseness=0.8]node[pos=0.7,sloped]{7} (4.-75);
    \draw[ArrowBlack] (13.75) to[out=75, in=90,looseness=0.5]node[pos=0.7,sloped]{8} (6.north);
    \draw[ArrowBlack] (13.105) to[out=90, in=90,looseness=0.8]node[pos=0.7,sloped]{9} (10.75);
    \draw[red,<->] (10.south) to[out=-90, in=-90,looseness=0.8]node[pos=0.7,sloped]{10} (13.south);
    \draw[ArrowRed] (5.-55) to[out=-90, in=-125,looseness=1]node[pos=0.7,sloped]{11} (6.-125);
    \draw[ArrowRed] (5.south) to[out=-90, in=-90,looseness=2]node[pos=0.7,sloped]{12} (7.south);
    \draw[ArrowRed] (5.-125) to[out=-105, in=-55,looseness=2]node[pos=0.7,sloped]{13} (8.-55);
    \draw[ArrowRed] (6.south) to[out=-90, in=-90,looseness=1.7]node[pos=0.7,sloped]{14} (8.south);
    \draw[ArrowGreen] (7.-55) to[out=-85, in=-125,looseness=1.2]node[pos=0.7,sloped]{15} (8.-125);
    \draw[ArrowGreen] (7.-125) to[out=-90, in=-55,looseness=1.5]node[pos=0.7,sloped]{16} (6.-55);
    \draw[ArrowRed] (2.north) to[out=90, in=90,looseness=1]node[pos=0.7,sloped]{17} (4.north);
    %Example
    \node[NodeFancy,above left=1cm of 1] (N-FANCY) {Example};
    \draw[ArrowGreen] (N-FANCY.center)  -- node[pos=0.7,sloped]{1cm}(1.center); %using positioning
    \draw[ArrowRed] (N-FANCY.-135) to[out=-135, in=135,looseness=10]node[pos=0.7,sloped]{example} (N-FANCY.135);
    \draw[ArrowGreen] (N-FANCY.center)  -- node[pos=0.7,sloped]{-135}++(-135:3); 
    \draw[ArrowGreen] (N-FANCY.center)  -- node[pos=0.7,sloped]{135}++(135:3); 
    
    
    \end{tikzpicture} 
\end{document}

答案2

关于这个问题:有没有办法让箭头的入口偏移到矩形?

你可以这样做shorten >= 4pt

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath,amssymb}
\usepackage{amsthm}
\usepackage{forest}
\usepackage{tikz}
\usepackage{pdflscape}
\pagenumbering{gobble}

\usetikzlibrary{positioning,calc,arrows.meta}%arrows is deprecated

\begin{document}

\begin{landscape}

\begin{figure}[htbp]
    \centering
    \begin{tikzpicture}[->,>=Stealth,auto,scale=0.6,shorten >= 4pt,
        very thick,main node/.style={draw, rectangle, align=center}]

\node[main node,text width=2cm] (1) at (0,14)    {$\text{shared\_info}$};
\node[main node,text width=2cm, anchor=north west] (2) at(1.north east) {$\text{outer\_names}$};
\node[main node,text width=2cm, anchor=south west] (3) at(2.north east) {$\text{all\_names}$};
\node[main node,text width=2cm, anchor=north west] (4) at(3.north east) {$\text{msgs}$};


\node[main node,text width=2cm] (5) at (-8,0)    {$\text{shared\_info}$};
\node[main node,text width=2cm, anchor=north west] (6) at(5.north east) {$\text{assigned\_in}$};
\node[main node,text width=2cm, anchor=south west] (7) at(6.north east) {$\text{all\_names}$};
\node[main node,text width=2cm, anchor=north west] (8) at(7.north east) {$\text{msgs}$};


\node[main node,text width=2cm] (9) at (8,0)    {$\text{shared\_info}$};
\node[main node,text width=2cm, anchor=north west] (10) at(9.north east) {$\text{assigned\_in}$};
\node[main node,text width=2cm, anchor=south west] (11) at(10.north east) {$\text{all\_names}$};
\node[main node,text width=2cm, anchor=north west] (12) at(11.north east) {$\text{msgs}$};
\node[main node,text width=2cm, anchor=north west] (13) at(12.north east) {$\text{assigned\_out}$};

\draw[black] (1.south) to[out=-90, in=90,looseness=0.8] (5.north);
\draw[black] (1.south) to[out=-90, in=90,looseness=0.8] (9.north);

\draw[black] (2.south) to[out=-90, in=90,looseness=0.8] (10.north);


\draw[black] (7.north) to[out=90, in=-90,looseness=0.8] (3.south);

\draw[black] (8.north) to[out=90, in=-90,looseness=0.8] (4.south);

\draw[black] (11.north) to[out=90, in=-90,looseness=0.8] (3.south);

\draw[black] (12.north) to[out=90, in=-90,looseness=0.8] (4.south);

\draw[black] (13.north) to[out=90, in=90,looseness=0.8] (6.north);
\draw[black] (13.north) to[out=90, in=90,looseness=0.8] (10.north);

\draw[red] (10.south) to[out=-90, in=-90,looseness=0.8] (13.south);

\draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (6.south);
\draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (7.south);
\draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (8.south);

\draw[blue,dotted] (6.south) to[out=-90, in=-90,looseness=1] (8.south);

\draw[green!50!black,dotted] (7.south) to[out=-90, in=-90,looseness=1] (8.south);
\draw[green!50!black,dotted] (7.south) to[out=-90, in=-90,looseness=1] (6.south);


\draw[red,dotted] (2.north) to[out=90, in=90,looseness=1] (4.north);

\end{tikzpicture} 


\end{figure}

\end{landscape}


\end{document}

在此处输入图片描述

答案3

作为@J Leon V. 答案的补充。主要区别在于更简单和更简短的图像代码:

\documentclass{article}
\usepackage[margin=25mm]{geometry}

\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                bending,
                positioning,
                }

\usepackage{pdflscape}
\pagenumbering{gobble}


\begin{document}

\begin{landscape}
%\noindent\rule{\linewidth}{2pt}
\begin{figure}[htbp]
    \centering
    \begin{tikzpicture}[%scale=0.6,
node distance = 0pt,
every edge/.style = {draw, very thick, -{Stealth[bend]} },
    mn/.style = {draw, thick, inner sep=2mm, text depth=0.5ex,
                 text height=2.2ex, text width=2cm, align=center,
                 outer sep=0pt},
                        ]

\node[mn] (1) at (0,8)      {shared\_info};
\node[mn, right=of 1]   (2) {outer\_names};
\node[mn,
      above right=of 2] (3) {all\_names};
\node[mn, right=of 3]   (4) {msgs};
%
\node[mn,
      below left=8 and 2.4 of 1]    (5) {shared\_info};
\node[mn, right=of 5]               (6) {assigned\_in};
\node[mn, above right=of 6]         (7) {all\_names};
\node[mn, right=of 7]               (8) {msgs};
%
\node[mn,
      below right=0 and 0.4 of 8]   (9)     {shared\_info};
\node[mn, right=of 9]               (10)    {assigned\_in};
\node[mn, above right=of 10]        (11)    {all\_names};
\node[mn, right=of 11]              (12)    {msgs};
\node[mn, right=of 12]              (13)    {assigned\_out};
%
\draw   (1.250) edge[out=-90, in= 90] (5)
        (1.290) edge[out=-90, in= 90] (9)
        (2)     edge[out=-90, in= 90] (10.110)
        (7)     edge[out= 90, in=-90] (3.250)
        (8)     edge[out= 90, in=-90] (4.250)
        (11)    edge[out= 90, in=-90] (3.290)
        (12)    edge[out= 90, in=-90] (4.290)
        (13.70)     edge[out= 90, in= 90] (6)
        (13.110)    edge[out= 90, in= 90] (10.70)
        (10)    edge[out=-90, in=-90, red] (13);
\draw[red,dash dot]   
        (5.290) edge[out=-90, in=-90] (6.250)
        (5)     edge[out=-90, in=-90] (7)
        (5.250) edge[out=-90, in=-90] (8.290);
\draw[blue,dotted]  
        (6)     edge[out=-90, in=-90] (8);
\draw[green!50!black,dotted] 
        (7.290)     edge[out=-90, in=-90] (8.250)
        (7.250)     edge[out=-90, in=-90] (6.290);
\draw[red,dotted] 
        (2)     edge[out= 90, in= 90] (4);

    \end{tikzpicture}
\end{figure}
    \end{landscape}
\end{document}

在此处输入图片描述

相关内容