Fishbone Ishikawa帮助的Latex Tikz代码

时间:2019-06-23 06:36:46

标签: latex tikz

我正在尝试在鱼骨图中添加箭头标签,我该如何给标签添加文本。我正在修改代码以满足我在https://texwelt.de/wissen/fragen/13171/ishikawa-tikz-diagram

中找到的需求

如果不是节点,如何在(@-\ r- \ c-2)创建的行上方添加文本? @-\ r- \ c-2符号是什么意思?

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows,shapes.geometric,positioning,matrix}
\tikzset{
  ishikawa/.style={align=center, inner sep=0pt},
  matter/.style  ={rectangle, minimum size=6mm, very thick, draw=red!70!black!40,
    top color=white, bottom color=red!50!black!20, font=\itshape},
  level_1/.style ={ellipse, node distance=60pt, minimum size=6mm, very thick,
    draw=red!50!black!50, top color=white, bottom color=red!50!black!20, font=\itshape},
  level_2/.style={rectangle, minimum size=6mm, font=\itshape, font=\tiny}}
\tikzset{
  rows/.style 2 args={@/.style={row ##1/.style={#2}},@/.list={#1}},
  cols/.style 2 args={@/.style={column ##1/.style={#2}},@/.list={#1}},
}
\begin{document}
\begin{tikzpicture}
\matrix[
  matrix of nodes,
  row sep=3cm,
  column sep=1cm,
  rows={1,3}{nodes=level_1},
  rows=2{nodes=matter,anchor=center}
] (m) {
Material & Machine & Measurement & \\
         &          &           & CPA \\
Method  & Man   & Mother Nature     & \\
};
\path[very thick,
  to arr/.style={->, shorten <=+0pt, shorten >=+.1cm},
  fr arr/.style={<-, shorten >=+0pt, shorten <=+.1cm}]
  [to arr]
  (m-1-1|-m-2-4) edge (m-2-4)
  \foreach \r [evaluate={\xslant=\r==3?.5:-.5;}] in {1,3}{%\xslant=\r==3?.5:-.5; impacts the position of the 6 main arrows in relation to the main BONE
    \foreach \c in {1,2,3}{ %tells where to make the bones if it is only 1, then only material and method is created
      (m-\r-\c) edge[xslant=\xslant]
        coordinate[pos=.5]   (@-\r-\c-1)
    coordinate[pos=.3]   (@-\r-\c-3)%i added this one
        coordinate[near end] (@-\r-\c-2) (m-\r-\c|-m-2-4)
%------------------------------------above makes the 6 main pillers
%-----------bottom code ass the horizontal arrows to each
     %controls arrow direction
}}
 [fr arr]
 \foreach \r in {3}{ %1 or 3 moves up or down
 \foreach \c in {2}{ %1 2 or 3 controls which section 

       (@-\r-\c-2) edge ++ (left:2cm) %middle horizontals

    %(@-\r-\c-3) edge ++ (left:2cm)%i added this one
    }
  }
  \foreach \prt in {1,2}{
  (@-1-1-\prt) --
    coordinate[pos=.3]   (@1-\prt)
    coordinate[near end] (@2-\prt) ++ (left:5cm)%paper width
 % [fr arr]
 % (@1-\prt) edge ++ ([xslant=-.5]up:.8cm) % extra arrows
 % (@2-\prt) edge ++ ([xslant=-.5]up:.8cm) % extra arrows
  };
\end{tikzpicture}
\end{document}

Image of my current fishbone diagram

1 个答案:

答案 0 :(得分:1)

我已经在https://texwelt.de/fragen/13171/ishikawa-tikz-diagram中使用了示例,并以非迭代(且更为冗长)的方式将其添加了文字标签。

结果:

[1]

乳胶代码:

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows,shapes.geometric,positioning,matrix}
\tikzset{
  ishikawa/.style={align=center, inner sep=0pt},
  matter/.style  ={rectangle, minimum size=6mm, very thick, draw=red!70!black!40,
    top color=white, bottom color=red!50!black!20, font=\itshape},
  level_1/.style ={ellipse, node distance=60pt, minimum size=6mm, very thick,
    draw=red!50!black!50, top color=white, bottom color=red!50!black!20, font=\itshape},
  level_2/.style={rectangle, minimum size=6mm, font=\itshape, font=\scriptsize}}
\tikzset{
  rows/.style 2 args={@/.style={row ##1/.style={#2}},@/.list={#1}},
  cols/.style 2 args={@/.style={column ##1/.style={#2}},@/.list={#1}},
}
\begin{document}
\begin{tikzpicture}
\matrix[
  matrix of nodes,
  row sep=3cm,
  column sep=1cm,
  rows={1,3}{nodes=level_1},
  rows={2}{nodes=matter,anchor=center}
] (m) {
The Cause 1 & The Cause 2 & The Cause 3 & \\
         &         &             & The Effect \\
The Cause 4  & The Cause 5  & The Cause 6     & \\
};
\path[very thick,
  toarr/.style={->, shorten <=+0pt, shorten >=+.1cm},
  fromarr/.style={<-, shorten >=+0pt, shorten <=+.1cm}]

  % Mid left to right arrow
  [toarr]
  (m-1-1|-m-2-4) edge (m-2-4)

  % The Cause 1 arrows
  (m-1-1) edge[xslant=-.5]
    coordinate[pos=.3]   (@-1-1-1)
    coordinate[near end] (@-1-1-2) (m-1-1|-m-2-4)
  [fromarr]
  (@-1-1-1) edge node[above, level_2]{Subcause 1} ++ (left:2cm)
  (@-1-1-2) edge node[above, level_2]{Subcause 2} ++ (left:2cm)

  % The Cause 2 arrows
  (m-1-2) edge[xslant=-.5]
    coordinate[pos=.3]   (@-1-2-1)
    coordinate[near end] (@-1-2-2) (m-1-2|-m-2-4)
  [fromarr]
  (@-1-2-1) edge node[above, level_2]{Subcause 1} ++ (left:2cm)
  (@-1-2-2) edge node[above, level_2]{Subcause 2} ++ (left:2cm)

  % The Cause 3 arrows
  (m-1-3) edge[xslant=-.5]
    coordinate[pos=.3]   (@-1-3-1)
    coordinate[near end] (@-1-3-2) (m-1-3|-m-2-4)
  [fromarr]
  (@-1-3-1) edge node[above, level_2]{Subcause 1} ++ (left:2cm)
  (@-1-3-2) edge node[above, level_2]{Subcause 2} ++ (left:2cm)

  % The Cause 4 arrows
  (m-3-1) edge[xslant=.5]
    coordinate[pos=.3]   (@-3-1-1)
    coordinate[near end] (@-3-1-2) (m-3-1|-m-2-4)
  [fromarr]
  (@-3-1-1) edge node[above, level_2]{Subcause 1} ++ (left:2cm)
  (@-3-1-2) edge node[above, level_2]{Subcause 2} ++ (left:2cm)

  % The Cause 5 arrows
  (m-3-2) edge[xslant=.5]
    coordinate[pos=.3]   (@-3-2-1)
    coordinate[near end] (@-3-2-2) (m-3-2|-m-2-4)
  [fromarr]
  (@-3-2-1) edge node[above, level_2]{Subcause 1} ++ (left:2cm)
  (@-3-2-2) edge node[above, level_2]{Subcause 2} ++ (left:2cm)

  % The Cause 6 arrows
  (m-3-3) edge[xslant=.5]
    coordinate[pos=.3]   (@-3-3-1)
    coordinate[near end] (@-3-3-2) (m-3-3|-m-2-4)
  [fromarr]
  (@-3-3-1) edge node[above, level_2]{Subcause 1} ++ (left:2cm)
  (@-3-3-2) edge node[above, level_2]{Subcause 2} ++ (left:2cm);
\end{tikzpicture}
\end{document}

要生成pdf:

pdflatex fishbone.tex