TikZ 데이터 시각화를 사용하여 프로세스 다이어그램에 화살표 팁(흐름 방향 달성)을 추가하는 방법은 무엇입니까?

TikZ 데이터 시각화를 사용하여 프로세스 다이어그램에 화살표 팁(흐름 방향 달성)을 추가하는 방법은 무엇입니까?

코드를 다음에서 수정했습니다.여기. 나는 두 가지 방법을 시도했습니다.

1.(원천):

\documentclass{scrartcl}
\usepackage{tikz}
\usepackage[per-mode = fraction]{siunitx}
\usetikzlibrary{datavisualization.formats.functions,
                decorations.markings
               }
\begin{document}
  \begin{tikzpicture}
    \datavisualization[scientific axes = {clean,
                                          end labels
                                         },
                       x axis = {label = $\frac{v}{\si{\cubic\m\per\kg}}$},
                       y axis = {label = $\frac{p}{\si{\bar}}$},
                       data/format = function,
                       visualize as smooth line/.list = {isentropic_press,
                                                         isobaric,
                                                         isentropic_decompress
                                                        },
                       style sheet = vary dashing,
                       every visualizer/.style = {decoration = {markings,
                                                                mark = at position .5 with {\arrow{>}}
                                                               }
                                                 },
                       isentropic_press = {label in legend = {text = isentrope Verdichtung}},
                       isobaric = {label in legend = {text = isobare Abkühlung}},
                       isentropic_decompress = {label in legend = {text = isentrope Entspannung}}
                      ]
    data[set = isentropic_press] {var x : interval[.5 : 2];
                                  func y = 1 / \value x ^ 1.4;
                                 }
    data[set = isobaric] {var x : interval[.5 : 1];
                          func y = 1 / .5 ^ 1.4;
                         }
    data[set = isentropic_decompress] {var x : interval[1 : 2];
                                       func y = 1 / (\value x - .5) ^ 1.4;%-.5: shifts the function by - 0.5 to the right
                                      }
    %accents important points
    info {\draw (visualization cs:x = 2,
                                  y = {(1 / 2 ^ 1.4)}
                ) circle [radius = 1pt]
            node [right,
                  font = \footnotesize
                 ] {1};
         }
    info {\draw (visualization cs:x = .5,
                                  y = {(1 / .5 ^ 1.4)}
                ) circle [radius = 1pt]
            node [above,
                  font = \footnotesize
                 ] {2};
         }
    info {\draw (visualization cs:x = 1,
                                  y = {(1 / .5 ^ 1.4)}
                ) circle [radius = 1pt]
            node [above,
                  font = \footnotesize
                 ] {3};
         }
    info {\draw (visualization cs:x = 2,
                                  y = {(1 / 1.5 ^ 1.4)}
                ) circle [radius = 1pt]
            node [right,
                  font = \footnotesize
                 ] {4};
         };
  \end{tikzpicture}
\end{document}

2.(원천):

\documentclass{scrartcl}
\usepackage{tikz}
\usepackage[per-mode = fraction]{siunitx}
\usetikzlibrary{datavisualization.formats.functions,
                decorations.markings
               }
\begin{document}
  \makeatletter
    \tikzset{nomorepostaction/.code = {\let\tikz@postactions\pgfutil@empty}}
  \makeatother
  \begin{tikzpicture}
    \datavisualization[scientific axes = {clean,
                                          end labels
                                         },
                       x axis = {label = $\frac{v}{\si{\cubic\m\per\kg}}$},
                       y axis = {label = $\frac{p}{\si{\bar}}$},
                       data/format = function,
                       visualize as smooth line/.list = {isentropic_press,
                                                         isobaric,
                                                         isentropic_decompress
                       },
                       style sheet = vary dashing,
                       every visualizer/.style = {postaction = {nomorepostaction,
                                                                decorate,
                                                                decoration = {markings,
                                                                              mark = at position .5 with {\arrow{>}}
                                                                             }
                                                               }
                                                 },
                       isentropic_press = {label in legend = {text = isentrope Verdichtung}},
                       isobaric = {label in legend = {text = isobare Abkühlung}},
                       isentropic_decompress = {label in legend = {text = isentrope Entspannung}}
                      ]
      data[set = isentropic_press] {var x : interval[.5 : 2];
                                    func y = 1 / \value x ^ 1.4;
                                   }
      data[set = isobaric] {var x : interval[.5 : 1];
                            func y = 1 / .5 ^ 1.4;
                           }
      data[set = isentropic_decompress] {var x : interval[1 : 2];
                                         func y = 1 / (\value x - .5) ^ 1.4;%-.5: shifts the function by - 0.5 to the right
                                        }
      %accents important points
      info {\draw (visualization cs:x = 2,
                                    y = {(1 / 2 ^ 1.4)}
                  ) circle [radius = 1pt]
              node [right,
                    font = \footnotesize
                   ] {1};
           }
      info {\draw (visualization cs:x = .5,
                                    y = {(1 / .5 ^ 1.4)}
                  ) circle [radius = 1pt]
              node [above,
                    font = \footnotesize
                   ] {2};
           }
      info {\draw (visualization cs:x = 1,
                                    y = {(1 / .5 ^ 1.4)}
                  ) circle [radius = 1pt]
              node [above,
                    font = \footnotesize
                   ] {3};
           }
      info {\draw (visualization cs:x = 2,
                                    y = {(1 / 1.5 ^ 1.4)}
                  ) circle [radius = 1pt]
              node [right,
                    font = \footnotesize
                   ] {4};
           };
  \end{tikzpicture}
\end{document}

그러나 두 경우 모두 결과는 동일합니다.

결과

내가 뭘 잘못했나요? 다음과 같이 하려면 어떻게 해야 합니까(화살표 끝이 거의 두 점 사이에 있음):

소망

미리 여러분의 도움과 노력에 감사드립니다!

답변1

다음은 모든 데이터 세트를 두 개로 분할하여 하나는 화살표로 끝나고 다른 하나는 화살표로 끝나지 않는다는 점을 제외하고 둘 다 동일한 스타일을 갖도록 만드는 방법입니다. 저는 이 datavisualization패키지에 대해 잘 알지 못하지만 함수를 그리는 것 같기 때문에 함수의 "중간" 지점을 찾으려면 곡선의 호 길이를 찾아야 하는데, 이에 TikZ대한 기능이 있는지 잘 모르겠습니다. 내 접근 방식에서는 화살표가 곡선의 "중간"에 나타나도록 하기 위해 일부 간격이 도메인의 중간으로 분할되고 일부는 그렇지 않은 것을 볼 수 있습니다.

결과는 다음과 같습니다.

여기에 이미지 설명을 입력하세요

다음은 코드입니다(일부 공백이 제거됨).

\documentclass{scrartcl}
\usepackage{tikz}
\usepackage[per-mode = fraction]{siunitx}
\usetikzlibrary{datavisualization.formats.functions,arrows.meta}
\begin{document}
\begin{tikzpicture}[
  % Arrow styles for both ends of lines
  midarrA/.style={-{Straight Barb[width=4pt,length=4pt,line width=1pt]}},
  midarrB/.style={{Straight Barb[width=4pt,length=4pt,line width=1pt]}-}
]
\datavisualization[
  scientific axes = {clean,end labels},
  x axis = {label = $\frac{v}{\si{\cubic\m\per\kg}}$},
  y axis = {label = $\frac{p}{\si{\bar}}$},
  data/format = function,
  % Two parts for each data set
  visualize as smooth line/.list = {
    isentropic_press 1, isentropic_press 2,
    isobaric 1, isobaric 2,
    isentropic_decompress 1, isentropic_decompress 2
  },
  style sheet = vary dashing,
  % Manually set pairs of data sets to have the same style
  /data point/set/isentropic_press 1/.initial=1,
  /data point/set/isentropic_press 2/.initial=1, 
  /data point/set/isobaric 1/.initial=2,
  /data point/set/isobaric 2/.initial=2, 
  /data point/set/isentropic_decompress 1/.initial=3,
  /data point/set/isentropic_decompress 2/.initial=3, 
  % Manually choose which part has the arrow at the end or beginning
  isentropic_press 1 = {label in legend = {text = isentrope Verdichtung}},
  isentropic_press 2 = {style={midarrB}},
  isobaric 1 = {style={midarrA}},
  isobaric 2 = {label in legend = {text = isobare Abkühlung}},
  isentropic_decompress 1 = {style={midarrA}},
  isentropic_decompress 2 = {label in legend = {text = isentrope Entspannung}}
]

% Split intervals of data sets as appropriate
data[set = isentropic_press 1] {var x : interval[.5:1]; func y = 1 / \value x ^ 1.4;}
data[set = isentropic_press 2] {var x : interval[1:2]; func y = 1 / \value x ^ 1.4;}
data[set = isobaric 1] {var x : interval[.5:.75]; func y = 1 / .5 ^ 1.4;}
data[set = isobaric 2] {var x : interval[.75:1]; func y = 1 / .5 ^ 1.4;}
data[set = isentropic_decompress 1] {var x : interval[1:1.35]; func y = 1 / (\value x - .5) ^ 1.4;}
data[set = isentropic_decompress 2] {var x : interval[1.35:2]; func y = 1 / (\value x - .5) ^ 1.4;}

% Accent important points
info {\draw (visualization cs:x = 2, y = {(1 / 2 ^ 1.4)}) circle [radius = 1pt] node [right, font = \footnotesize] {1};}
info {\draw (visualization cs:x = .5, y = {(1 / .5 ^ 1.4)}) circle [radius = 1pt] node [above, font = \footnotesize] {2};}
info {\draw (visualization cs:x = 1, y = {(1 / .5 ^ 1.4)}) circle [radius = 1pt] node [above, font = \footnotesize] {3};}
info {\draw (visualization cs:x = 2, y = {(1 / 1.5 ^ 1.4)}) circle [radius = 1pt] node [right, font = \footnotesize] {4};};
\end{tikzpicture}
\end{document}

아마도 나보다 더 똑똑한 누군가가 이것을 매크로로 만들 수 있을 것입니다.

답변2

나는 당신의 모범이 원하는 방식으로 협력하도록 노력했지만 부끄럽게도 실패했습니다. 솔루션이 pgfplots귀하에게 유용할까요?

결과:

결과

\documentclass[margin=2mm,tikz]{standalone}
\usepackage{pgfplots}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usetikzlibrary{decorations.markings}
\usepackage[per-mode = fraction]{siunitx}

\begin{document}
\begin{tikzpicture}

    \begin{axis}[
            cycle list name=linestyles,
            legend style={
                cells={anchor=east},
                legend pos=outer north east,
            },
            xlabel = {$\frac{v}{\si{\cubic\m\per\kg}}$},
            ylabel = {$\frac{p}{\si{\bar}}$},
            xlabel style = {at={(axis description cs:1.1,0.2)}},
            ylabel style = {at={(axis description cs:0.1,1.1)},rotate=-90},
        ]

        \addplot+[
            domain=2:0.5,
            decoration={
                markings,
                mark=at position 0.5 with {\arrow [scale=1.5]{stealth}}},
            postaction={decorate},
        ] {1/(x^1.4)};
        \addplot+[
            domain=0.5:1,
            decoration={
                markings,
                mark=at position 0.5 with {\arrow [scale=1.5]{stealth}}},
            %postaction={nomorepostaction,decorate},
            postaction={decorate},
        ] {1/(0.5^1.4)};
        \addplot+[
            domain=1:2,
            decoration={
                markings,
                mark=at position 0.5 with {\arrow [scale=1.5]{stealth}}},
            postaction={decorate},
        ] {1/((x-0.5)^1.4)};

        \draw (axis cs:2,1/2^1.4)     circle (1pt) node[right,font=\footnotesize] {1};
        \draw (axis cs:0.5,1/0.5^1.4) circle (1pt) node[above,font=\footnotesize] {2};
        \draw (axis cs:1.0,1/0.5^1.4) circle (1pt) node[above,font=\footnotesize] {3};
        \draw (axis cs:2,1/1.5^1.4)   circle (1pt) node[right,font=\footnotesize] {4};

        \legend{isentrope Verdichtung,isobare Abkühlung,isentrope Entspannung}
    \end{axis}

\end{tikzpicture}
\end{document}

관련 정보