Wie füge ich mit der TikZ-Datenvisualisierung einem Prozessdiagramm Pfeilspitzen hinzu (um die Flussrichtung festzulegen)?

Wie füge ich mit der TikZ-Datenvisualisierung einem Prozessdiagramm Pfeilspitzen hinzu (um die Flussrichtung festzulegen)?

Ich habe den Code von geändertHierIch habe es auf zwei Arten versucht.

1.(Quelle):

\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.(Quelle):

\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}

Das Ergebnis ist jedoch in beiden Fällen dasselbe:

Ergebnis

Was mache ich falsch? Wie kann ich so etwas machen (Pfeilspitzen ungefähr zwischen zwei Punkten):

Wunsch

Vielen Dank im Voraus für Ihre Hilfe und Mühe!

Antwort1

Hier ist eine Methode, die jeden Datensatz in zwei Teile aufteilt und dafür sorgt, dass beide den gleichen Stil haben, außer dass einer mit einem Pfeil endet und der andere nicht. Ich bin mit dem datavisualizationPaket nicht so vertraut, aber da es anscheinend Funktionen darstellt, müsste man, um den „Halbpunkt“ einer Funktion zu finden, die Bogenlänge einer Kurve finden, und ich bin mir nicht sicher, ob es TikZdie Möglichkeiten dazu gibt. Bei meinem Ansatz können Sie sehen, dass einige Intervalle in Bezug auf die Domäne in der Mitte geteilt sind, andere nicht, damit der Pfeil in der „Mitte“ der Kurve erscheint.

Dies ist das Ergebnis:

Bildbeschreibung hier eingeben

Dies ist der Code (nachdem einige Leerzeichen entfernt wurden):

\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}

Vielleicht kann jemand, der schlauer ist als ich, daraus ein Makro machen.

Antwort2

Ich habe versucht, Ihr Beispiel dazu zu bringen, in der gewünschten Weise mitzumachen, und bin dabei kläglich gescheitert. Wäre eine Lösung pgfplotsfür Sie von Nutzen?

Ergebnis:

Ergebnis

\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}

verwandte Informationen