|
Was kann ich einstellen, damit meine Pfeilbeschriftung exakt auf einer Höhe ist und nicht bei jedem beschrifteten Pfeil verschieden? Ich versuche es nun schon eine ganze Weile, aber habe bisher noch keine Lösung für mein Problem gefunden. Folgend ein Beispiel. Ich möchte am Ende alle T's auf die Höhe von T_2 anpassen und suche nach einer Lösung dafür. Schonmal vielen Dank! \documentclass{scrarticle} \usepackage{tikz,pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{arrows,trees,graphs,positioning, arrows, chains, shapes, arrows.meta,decorations.pathreplacing} \begin{document} \begin{figure}[h] \begin{tikzpicture}[>=Stealth] % Koordinatensystem \draw[->,>=Stealth,thick] (0,0) -- (12.5,0) node[below=0.2] {x}; \draw[->,thick] (0,0) -- (0,6) node[below left=0.3,anchor=east] {y}; \begin{scope}[ultra thin,every edge/.append style={->}] \foreach [count=\i] \x/\y in { 0.2/5, 2.7/4.6, 5.2/3.7, 7.7/3.4, 10.2/4.4 }{ \path (\x,0) -- (\x,\y) node (h) [pos=.6] {~$T_\i$}; \path (h) edge (\x,0) edge (\x,\y); } \end{scope} \end{tikzpicture} \end{figure} \end{document} |
|
Du kannst einfach eine feste vertikale Position für die Tᵢ vorgeben, z.B. y=2.8. Dann kann auch auf den Hilfsnode \path (\x,2.8) node {~$T_\i$} edge (\x,0) edge (\x,\y); Beispiel: \documentclass{scrartcl} \usepackage{tikz} \usetikzlibrary{arrows.meta} \begin{document} \begin{figure}[htp] \begin{tikzpicture}[>=Stealth] % Koordinatensystem \draw[->,>=Stealth,thick] (0,0) -- (12.5,0) node[below=0.2] {x}; \draw[->,thick] (0,0) -- (0,6) node[below left=0.3,anchor=east] {y}; \begin{scope}[ultra thin,every edge/.append style={->}] \foreach [count=\i] \x/\y in { 0.2/5, 2.7/4.6, 5.2/3.7, 7.7/3.4, 10.2/4.4 }{ \path (\x,2.8) node {~$T_\i$} edge (\x,0) edge (\x,\y);% Beschriftung wird bei y=2.8 eingefügt } \end{scope} \end{tikzpicture} \end{figure} \end{document} Vielen Dank!
(01 Jun '21, 15:30)
lina_36
|
|
Die Beschriftung soll also einheitlich bei 60% von 4.6=yUse erscheinen; dann musst Du die \pgfmathsetmacro\yUse{4.6} \pgfmathsetmacro\Tpos{0.6*\yUse/\y} \path (\x,0) -- (\x,\y) node (h) [pos=\Tpos] {~$T_\i$}; Damit: \documentclass{scrarticle} \usepackage{tikz,pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{arrows.meta} \begin{document} \begin{figure}[h] \begin{tikzpicture}[>=Stealth] % Koordinatensystem \draw[->,>=Stealth,thick] (0,0) -- (12.5,0) node[below=0.2] {x}; \draw[->,thick] (0,0) -- (0,6) node[below left=0.3,anchor=east] {y}; \pgfmathsetmacro\yUse{4.6} \begin{scope}[ultra thin,every edge/.append style={->}] \foreach [count=\i] \x/\y in { 0.2/5, 2.7/4.6, 5.2/3.7, 7.7/3.4, 10.2/4.4 }{ \pgfmathsetmacro\Tpos{0.6*\yUse/\y} \path (\x,0) -- (\x,\y) node (h) [pos=\Tpos] {~$T_\i$}; \path (h) edge (\x,0) edge (\x,\y); \node[anchor=north west, font=\footnotesize, red] at (\x,0.9*\Tpos*\y) {(\Tpos)}; % zur Anzeige } \end{scope} \end{tikzpicture} \end{figure} \end{document} |

Du könntest in Zeile 23 Folgendes verwenden:
\path (\x,\y) -- (\x,0) node (h) [yshift=2cm] {~$T_\i$};Off topic: Wenn Du
arrows.metalädst, kannst Du eigentlich aucharrowsverzichten. Im Beispiel lädst Duarrowssogar doppelt. Das sollte man vermeiden, genau wie das Laden von im Code nicht verwendeten Dateien.pgfplotslädt automatischtikz. Wenn manpgfplotslädt, braucht man also nicht nochmaltikzzu laden. Für das Beispiel genügt abertikz.