我该如何修改箭头来补充该绘图?

我该如何修改箭头来补充该绘图?

回答这个问题后问题,现在我的箭头看起来非常不令人满意。

如果我使用命令double中的选项,\draw间距会太小,而当我增加间距时,箭头看起来很糟糕。目前,箭头看起来很小,而且位置不对;我想要宽箭头(双箭头),箭头细。

我如何修改箭头(最好以全局方式)以使它们与绘图保持一致?

和,如何修改箭头使它们垂直于其指向的表面?

在此处输入图片描述

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,fit}
\pgfdeclarelayer{container}
\pgfsetlayers{container,main}

\tikzset{>=stealth}
\tikzset{
    narrow/.style={draw, fill=blue!20, text width=2cm, text centered, minimum height=1cm},
    small/.style={draw, fill=blue!10, text width=1.2cm, text centered, minimum height=0.625cm, draw=black!60, font=\scriptsize},
    wide/.style={draw, fill=orange!20, text width=8.5cm, text centered, minimum height=1.75cm, rounded corners},
    tall/.style={draw, fill=green!20, text width=1.75cm, text centered, minimum height=8cm, rounded corners},
    squar/.style={draw, fill=yellow!10, text width=5.25cm, text centered, minimum height=3.5cm, rounded corners, draw=black!60, dashed}
}

\def\blockdist{5}
\def\edgedist{5}
\begin{document}
\begin{tikzpicture}
  \node                 (lib)     [tall]   {Library};
  \node at (3,-1)       (tman)    [narrow] {tmon};
  \node                 (ksman)   [narrow] [right=.75cm of tman]   {ksmon};
  \node                 (stsp)    [narrow] [right=.75cm of ksman]  {stosp};
  \node                 (daemon)  [wide]   [below=.75cm of ksman]  {Daemon};
  \node                 (imgan)   [narrow] [above=1.375cm of tman] {img-analysis};
  \node                 (thrman)  [narrow] [above=.75cm of imgan]  {thermal-analysis};
  \begin{pgfonlayer}{container}
     \node              (dio)     [fill=red!10, inner sep=.35cm, fit=(tman)(stsp),  rounded corners, draw=black!60, dashed] {};
     \node              (manufac) [fill=red!25, inner sep=.1cm, fit=(ksman)(stsp), rounded corners, draw=black!60, dashed] {};
  \end{pgfonlayer}
  \node                 (scrpts)  [squar]  [above=1.5cm of manufac.center] {};

  \node                 (scrr2c2) [small]  [above=0.1cm of scrpts.center] {shell};
  \node                 (scrr1c2) [small]  [above=0.2cm of scrr2c2]       {shell};
  \node                 (scrr3c2) [small]  [below=0.1cm of scrpts.center] {shell};
  \node                 (scrr4c2) [small]  [below=0.2cm of scrr3c2]       {shell};

  \node                     (scrr1c1) [small]  [left=0.2cm of scrr1c2] {shell};
  \node                     (scrr2c1) [small]  [left=0.2cm of scrr2c2] {shell};
  \node                     (scrr3c1) [small]  [left=0.2cm of scrr3c2] {shell};
  \node                     (scrr4c1) [small]  [left=0.2cm of scrr4c2] {shell};

  \node                     (scrr1c3) [small]  [right=0.2cm of scrr1c2] {shell};
  \node                     (scrr2c3) [small]  [right=0.2cm of scrr2c2] {shell};
  \node                     (scrr3c3) [small]  [right=0.2cm of scrr3c2] {shell};
  \node                     (scrr4c3) [small]  [right=0.2cm of scrr4c2] {shell};

  \draw[<->] (manufac.north) -- (scrpts.south);
  \draw[<->] (imgan.east) -- (scrpts);
  \draw[<->] (thrman.east) -- (scrpts);
  \draw[<->] (thrman.west) -- (lib);
  \draw[<->] (imgan.west) -- (lib);
  \draw[<->] (dio.west) -- (lib);
  \draw[<->] (daemon.west) -- (lib);
  \draw[<->] (daemon.north) -- (dio.south);
\end{tikzpicture}
\end{document}

答案1

要修改箭头及其头部,请参阅这个答案在一个有点相关的问题

对于垂直箭头,我知道的唯一方法是保存正确的(x,y)坐标,并将箭头连接到这些坐标。

垂直箭头

声明一些新的维度来保存坐标。

\newdimen{\myxdimone}
\newdimen{\myydimone}
\newdimen{\myxdimtwo}
\newdimen{\myydimtwo}

创建所需的路径,并使用 获取它们的 x,y 坐标\pgfgetlastxy{x}{y},例如

\path (thrman.west);
\pgfgetlastxy{\myxdimone}{\myydimone};
\path (lib.east);
\pgfgetlastxy{\myxdimtwo}{\myydimtwo};

现在根据保存的尺寸创建一个坐标并绘制箭头。

\coordinate (dummy1) at (\myxdimtwo, \myydimone);
\draw[<->] (thrman.west) -- (dummy1);

可能有更简单的解决方案,但这是我在类似情况下使用的方法。请参阅下面的完整代码。

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,fit}
\pgfdeclarelayer{container}
\pgfsetlayers{container,main}

\tikzset{>=stealth}
\tikzset{
    narrow/.style={draw, fill=blue!20, text width=2cm, text centered, minimum height=1cm},
    small/.style={draw, fill=blue!10, text width=1.2cm, text centered, minimum height=0.625cm, draw=black!60, font=\scriptsize},
    wide/.style={draw, fill=orange!20, text width=8.5cm, text centered, minimum height=1.75cm, rounded corners},
    tall/.style={draw, fill=green!20, text width=1.75cm, text centered, minimum height=8cm, rounded corners},
    squar/.style={draw, fill=yellow!10, text width=5.25cm, text centered, minimum height=3.5cm, rounded corners, draw=black!60, dashed}
}

\def\blockdist{5}
\def\edgedist{5}
\begin{document}
\begin{tikzpicture}

  \newdimen{\myxdimone}
  \newdimen{\myydimone}
  \newdimen{\myxdimtwo}
  \newdimen{\myydimtwo}

  \node                 (lib)     [tall]   {Library};
  \node at (3,-1)       (tman)    [narrow] {tmon};
  \node                 (ksman)   [narrow] [right=.75cm of tman]   {ksmon};
  \node                 (stsp)    [narrow] [right=.75cm of ksman]  {stosp};
  \node                 (daemon)  [wide]   [below=.75cm of ksman]  {Daemon};
  \node                 (imgan)   [narrow] [above=1.375cm of tman] {img-analysis};
  \node                 (thrman)  [narrow] [above=.75cm of imgan]  {thermal-analysis};
  \begin{pgfonlayer}{container}
     \node              (dio)     [fill=red!10, inner sep=.35cm, fit=(tman)(stsp),  rounded corners, draw=black!60, dashed] {};
     \node              (manufac) [fill=red!25, inner sep=.1cm, fit=(ksman)(stsp), rounded corners, draw=black!60, dashed] {};
  \end{pgfonlayer}
  \node                 (scrpts)  [squar]  [above=1.5cm of manufac.center] {};

  \node                 (scrr2c2) [small]  [above=0.1cm of scrpts.center] {shell};
  \node                 (scrr1c2) [small]  [above=0.2cm of scrr2c2]       {shell};
  \node                 (scrr3c2) [small]  [below=0.1cm of scrpts.center] {shell};
  \node                 (scrr4c2) [small]  [below=0.2cm of scrr3c2]       {shell};

  \node                     (scrr1c1) [small]  [left=0.2cm of scrr1c2] {shell};
  \node                     (scrr2c1) [small]  [left=0.2cm of scrr2c2] {shell};
  \node                     (scrr3c1) [small]  [left=0.2cm of scrr3c2] {shell};
  \node                     (scrr4c1) [small]  [left=0.2cm of scrr4c2] {shell};

  \node                     (scrr1c3) [small]  [right=0.2cm of scrr1c2] {shell};
  \node                     (scrr2c3) [small]  [right=0.2cm of scrr2c2] {shell};
  \node                     (scrr3c3) [small]  [right=0.2cm of scrr3c2] {shell};
  \node                     (scrr4c3) [small]  [right=0.2cm of scrr4c2] {shell};

  \draw[<->] (manufac.north) -- (scrpts.south);

  \path (thrman.west);
  \pgfgetlastxy{\myxdimone}{\myydimone};
  \path (lib.east);
  \pgfgetlastxy{\myxdimtwo}{\myydimtwo};
  \coordinate (dummy1) at (\myxdimtwo, \myydimone);
  \draw[<->] (thrman.west) -- (dummy1);

  \path (imgan.west);
  \pgfgetlastxy{\myxdimone}{\myydimone};
  \coordinate (dummy2) at (\myxdimtwo, \myydimone);
  \draw[<->] (imgan.west) -- (dummy2);

  \path (dio.west);
  \pgfgetlastxy{\myxdimone}{\myydimone};
  \coordinate (dummy3) at (\myxdimtwo, \myydimone);
  \draw[<->] (dio.west) -- (dummy3);

  \path (daemon.west);
  \pgfgetlastxy{\myxdimone}{\myydimone};
  \coordinate (dummy4) at (\myxdimtwo, \myydimone);
  \draw[<->] (daemon.west) -- (dummy4);
  \draw[<->] (daemon.north) -- (dio.south);

  \path (scrpts.west);
  \pgfgetlastxy{\myxdimone}{\myydimone};
  \path (imgan.east);
  \pgfgetlastxy{\myxdimtwo}{\myydimtwo};
  \coordinate (dummy5) at (\myxdimone, \myydimtwo);
  \draw[<->] (imgan.east) -- (dummy5);

  \path (thrman.east);
  \pgfgetlastxy{\myxdimtwo}{\myydimtwo};
  \coordinate (dummy6) at (\myxdimone, \myydimtwo);
  \draw[<->] (thrman.east) -- (dummy6);
\end{tikzpicture}
\end{document}

答案2

当你说

\draw[<->] (imgan.east)--(scrpts);

coordinate imgan.east您正在绘制一个从到 的箭头coordinate scrpts.center,但箭头将停止在scrpts边界处。

如果要从imgan.east一条水平线imgan.east和一条垂直线的交点处画一条箭头,scrpts.west可以使用特殊语法

\draw[<->] (imgan.east) -- (imgan.east-|scrpts.west);

由于scrpts.westscrpts.center位于同一水平线上,因此您可以避免使用 进行一些输入(imgan.east-|scrpts)

改变

\draw[<->] (imgan.east) -- (scrpts);
\draw[<->] (thrman.east) -- (scrpts);
\draw[<->] (thrman.west) -- (lib);
\draw[<->] (imgan.west) -- (lib);
\draw[<->] (dio.west) -- (lib);
\draw[<->] (daemon.west) -- (lib);

\draw[<->] (thrman.east) -- (thrman.east-|scrpts.west);
\draw[<->] (thrman.west) -- (lib.east|-thrman);
\draw[<->] (imgan.west) -- (lib.east|-imgan);
\draw[<->] (dio.west) -- (lib.east|-dio);
\draw[<->] (daemon.west) -- (lib.east|-daemon);

您将获得期望的结果。

相关内容