Überarbeitungsverlauf[Zurück]
Klicke auf Einblenden/Ausblenden von Überarbeitungen 6

30 Aug '18, 11:38

cis's gravatar image

cis
9.5k102460491

Die folgende Lösung mit `\usepgfplotslibrary{patchplots}` genügt den drei Ansprüchen 1. Die Platzierung der Punkte (hier als vorhandener externer Datensatz angenommen) 2. Die Angabe der Verbindungskanten 3. Die geeignete Platzierung der Beschriftungen (keine Überlappungen o.ä.) hat aber den Nachteil, dass die Koordinatentabelle Nr x y Textposition \\ 0 0 0 south \\% Default 1 -1.23 4.58 \\ 2 -2.01 3.95 \\ 3 -1.07 3.59 north \\% Änderung 4 -1.85 2.96 south \\% Default wiederholen 5 -2.78 3.32 \\ .... zweimal angegeben werden muss: einmal für die Koordinatenpunkte, einmal für die Beschriftungen. *Das ist nicht unbedingt elegant, aber wird bereits im Handbuchbeispiel für 'patch plots polygon' so gemacht, daher schätze ich, dass es zur Zeit keine kürzere Lösung gibt (pgfplots 1.16, letztes Beispiel vor Abschnitt 5.9.2).* *(Überdies erlaubt pgfplots hier zur Zeit scheints nur inlinetables.)* Ansonsten können im patch-Plot die Verbindungen bequem in der Form patch table with point meta={% Startpkt Endpkt colordata \\%colordata weglassen, dann vermutl. autom. 0 1 1 \\ 2 1 \\ 3 1 \\ 3 2 \\ 4 3 \\ ... ... } eingegeben werden. **Vollständiges MWE:** [![alt text][1]][1] %\documentclass[]{article} \documentclass[margin=5mm, tikz]{standalone} \usepackage{pgfplots} \usepgfplotslibrary{patchplots} \pgfplotsset{compat=1.13} \begin{document} % Allgemeine Angaben \pgfplotsset{ x=15mm, y=15mm, % Maßstab % Oder Bildmaße % width=20cm, % height=5cm, } \begin{tikzpicture} \begin{axis}[hide axis, colormap={Kantenfarbe}{color=(gray) color=(gray)}, ] \addplot+[ % Punkte mark size=1.125pt, mark options={red}, % Kanten thick, % Beschriftung --> hier nicht möglich %nodes near coords=\coordindex, % TUT -hier- NICHT! table/row sep=\\, % Muss wohl so sein!? % patch, % Plot-Typ patch type=polygon, vertex count=2, % damit nur Kanten, keine Flächen, gezeichnet werden % % Angabe der Verbindungskanten ===================== patch table with point meta={% Startpkt Endpkt colordata \\%colordata weglassen, dann vermutl. autom. 0 1 1 \\ 2 1 \\ 3 1 \\ 3 2 \\ 4 3 \\ 4 2 \\ 4 43 \\ 5 4 \\ 5 2 \\ 5 37 \\ 6 1 \\ 7 1 \\ 7 6 \\ 8 7 \\ 8 6 \\ 9 7 \\ 9 8 \\ 10 9 \\ 10 8 \\ 11 9 \\ 11 10 \\ 12 11 \\ 13 11 \\ 13 12 \\ 14 13 \\ 14 12 \\ 15 13 \\ 15 14 \\ 16 15 \\ 17 15 \\ 17 16 \\ 18 17 \\ 18 16 \\ 19 17 \\ 19 18 \\ 20 19 \\ 21 19 \\ 21 20 \\ 22 21 \\ 22 20 \\ 23 21 \\ 23 22 \\ 24 23 \\ 25 23 \\ 25 24 \\ 26 25 \\ 26 24 \\ 27 25 \\ 27 26 \\ 28 27 \\ 28 26 \\ 29 27 \\ 29 28 \\ 29 31 \\ 30 31 \\ 30 29 \\ 31 33 \\ 32 33 \\ 32 31 \\ 32 30 \\ 33 33 \\ 34 35 \\ 34 33 \\ 34 36 \\ 35 33 \\ 36 37 \\ 36 35 \\ 36 38 \\ 37 35 \\ 38 5 \\ 38 37 \\ 39 32 \\ 39 30 \\ 40 34 \\ 40 39 \\ 41 39 \\ 41 28 \\ 42 41 \\ 42 24 \\ 42 22 \\ 43 38 \\ 43 40 \\ 44 41 \\ 44 42 \\ 44 49 \\ 44 51 \\ 45 6 \\ 45 3 \\ 46 14 \\ 46 12 \\ 46 48 \\ 47 18 \\ 47 16 \\ 48 10 \\ 48 45 \\ 48 50 \\ 49 45 \\ 49 43 \\ 49 40 \\ 50 47 \\ 50 46 \\ 50 51 \\ 51 20 \\ 51 47 \\ } % Angabe der Verbindungskanten ===================== ] table[header=true, x index=1, y index=2, row sep=\\] { Nr x y Textposition \\ 0 0 0 south \\ 1 -1.23 4.58 \\ 2 -2.01 3.95 \\ 3 -1.07 3.59 north \\ 4 -1.85 2.96 south \\ 5 -2.78 3.32 \\ 6 -0.97 3.62 \\ 7 -0.27 4.32 \\ 8 -0.01 3.36 \\ 9 0.70 4.06 \\ 10 0.96 3.10 \\ 11 1.67 3.81 \\ 12 1.34 2.86 \\ 13 2.32 3.05 \\ 14 1.99 2.10 \\ 15 2.97 2.29 \\ 16 2.04 1.93 north \\ 17 2.81 1.30 south \\ 18 1.88 0.95 \\ 19 2.66 0.31 \\ 20 1.66 0.43 \\ 21 2.06 -0.49 \\ 22 1.06 -0.37 \\ 23 1.46 -1.29 \\ 24 0.96 -0.42 north \\ 25 0.46 -1.28 south \\ 26 -0.04 -0.41 \\ 27 -0.54 -1.28 \\ 28 -1.04 -0.41 north \\ 29 -1.54 -1.27 south \\ 30 -1.16 -0.35 \\ 31 -2.15 -0.48 \\ 32 -1.77 0.44 \\ 33 -2.76 0.32 \\ 34 -1.90 0.82 \\ 35 -2.77 1.32 \\ 36 -1.90 1.82 \\ 37 -2.77 2.32 \\ 38 -1.91 2.82 north \\ 39 -0.77 0.57 south \\ 40 -1.16 1.50 \\ 41 -0.08 -0.14 \\ 42 0.66 0.54 north \\ 43 -0.97 2.48 south \\ 44 -0.30 0.83 \\ 45 -0.81 2.63 \\ 46 1.01 1.92 \\ 47 1.10 1.58 \\ 48 0.18 2.48 \\ 49 -0.21 1.83 \\ 50 0.11 1.48 \\ 51 0.69 0.67 \\ }; % Beschriftungen ============================ % Laut Handbuch "replicate the vertex list to show \coordindex" % Anzeigen des 0. Aliaspunktes verhindern: \newcommand\Punktnummer{\pgfmathparse{\punktnummer>0 ? \punktnummer : ""}\pgfmathresult} \addplot[ only marks, visualization depends on={value \thisrowno{0} \as \punktnummer}, visualization depends on={value \thisrowno{3} \as \Anker}, nodes near coords={\Punktnummer}, % every node near coord/.append style={ font=\scriptsize, %\sffamily text=black, anchor=\Anker }, ] table[header=true, x index=1, y index=2, row sep=\\] { Nr x y Textposition \\ 0 0 0 south \\ 1 -1.23 4.58 \\ 2 -2.01 3.95 \\ 3 -1.07 3.59 north \\ 4 -1.85 2.96 south \\ 5 -2.78 3.32 \\ 6 -0.97 3.62 \\ 7 -0.27 4.32 \\ 8 -0.01 3.36 \\ 9 0.70 4.06 \\ 10 0.96 3.10 \\ 11 1.67 3.81 \\ 12 1.34 2.86 \\ 13 2.32 3.05 \\ 14 1.99 2.10 \\ 15 2.97 2.29 \\ 16 2.04 1.93 north \\ 17 2.81 1.30 south \\ 18 1.88 0.95 \\ 19 2.66 0.31 \\ 20 1.66 0.43 \\ 21 2.06 -0.49 \\ 22 1.06 -0.37 \\ 23 1.46 -1.29 \\ 24 0.96 -0.42 north \\ 25 0.46 -1.28 south \\ 26 -0.04 -0.41 \\ 27 -0.54 -1.28 \\ 28 -1.04 -0.41 north \\ 29 -1.54 -1.27 south \\ 30 -1.16 -0.35 \\ 31 -2.15 -0.48 \\ 32 -1.77 0.44 \\ 33 -2.76 0.32 \\ 34 -1.90 0.82 \\ 35 -2.77 1.32 \\ 36 -1.90 1.82 \\ 37 -2.77 2.32 \\ 38 -1.91 2.82 north \\ 39 -0.77 0.57 south \\ 40 -1.16 1.50 \\ 41 -0.08 -0.14 \\ 42 0.66 0.54 north \\ 43 -0.97 2.48 south \\ 44 -0.30 0.83 \\ 45 -0.81 2.63 \\ 46 1.01 1.92 \\ 47 1.10 1.58 \\ 48 0.18 2.48 \\ 49 -0.21 1.83 \\ 50 0.11 1.48 \\ 51 0.69 0.67 \\ }; % Beschriftungen ============================ \end{axis} \end{tikzpicture} \end{document} [1]: https://texwelt.de/wissen/upfiles/Patch0b.png
Klicke auf Einblenden/Ausblenden von Überarbeitungen 5

29 Aug '18, 21:01

cis's gravatar image

cis
9.5k102460491

Die folgende Lösung mit `\usepgfplotslibrary{patchplots}` genügt den drei Ansprüchen 1. Die Platzierung der Punkte (hier als vorhandener externer Datensatz angenommen) 2. Die Angabe der Verbindungskanten 3. Die geeignete Platzierung der Beschriftungen (keine Überlappungen o.ä.) hat aber den Nachteil, dass die Koordinatentabelle Nr x y Textposition \\ 0 0 0 south \\% Default 1 -1.23 4.58 \\ 2 -2.01 3.95 \\ 3 -1.07 3.59 north \\% Änderung 4 -1.85 2.96 south \\% Default wiederholen 5 -2.78 3.32 \\ .... zweimal angegeben werden muss: einmal für die Koordinatenpunkte, einmal für die Beschriftungen. *(Überdies erlaubt pgfplots hier zur Zeit scheints nur inlinetables.)* Ansonsten können im patch-Plot die Verbindungen bequem in der Form patch table with point meta={% Startpkt Endpkt colordata \\%colordata weglassen, dann vermutl. autom. 0 1 1 \\ 2 1 \\ 3 1 \\ 3 2 \\ 4 3 \\ ... ... } eingegeben werden. **Vollständiges MWE:** [![alt text][1]][1] %\documentclass[]{article} \documentclass[margin=5mm, tikz]{standalone} \usepackage{pgfplots} \usepgfplotslibrary{patchplots} \pgfplotsset{compat=1.13} \begin{document} % Allgemeine Angaben \pgfplotsset{ x=15mm, y=15mm, % Maßstab % Oder Bildmaße % width=20cm, % height=5cm, } \begin{tikzpicture} \begin{axis}[hide axis, colormap={Kantenfarbe}{color=(gray) color=(gray)}, ] \addplot+[ % Punkte mark size=1.125pt, mark options={red}, % Kanten thick, % Beschriftung --> hier nicht möglich %nodes near coords=\coordindex, % TUT -hier- NICHT! table/row sep=\\, % Muss wohl so sein!? % patch, % Plot-Typ patch type=polygon, vertex count=2, % damit nur Kanten, keine Flächen, gezeichnet werden % % Angabe der Verbindungskanten ===================== patch table with point meta={% Startpkt Endpkt colordata \\%colordata weglassen, dann vermutl. autom. 0 1 1 \\ 2 1 \\ 3 1 \\ 3 2 \\ 4 3 \\ 4 2 \\ 4 43 \\ 5 4 \\ 5 2 \\ 5 37 \\ 6 1 \\ 7 1 \\ 7 6 \\ 8 7 \\ 8 6 \\ 9 7 \\ 9 8 \\ 10 9 \\ 10 8 \\ 11 9 \\ 11 10 \\ 12 11 \\ 13 11 \\ 13 12 \\ 14 13 \\ 14 12 \\ 15 13 \\ 15 14 \\ 16 15 \\ 17 15 \\ 17 16 \\ 18 17 \\ 18 16 \\ 19 17 \\ 19 18 \\ 20 19 \\ 21 19 \\ 21 20 \\ 22 21 \\ 22 20 \\ 23 21 \\ 23 22 \\ 24 23 \\ 25 23 \\ 25 24 \\ 26 25 \\ 26 24 \\ 27 25 \\ 27 26 \\ 28 27 \\ 28 26 \\ 29 27 \\ 29 28 \\ 29 31 \\ 30 31 \\ 30 29 \\ 31 33 \\ 32 33 \\ 32 31 \\ 32 30 \\ 33 33 \\ 34 35 \\ 34 33 \\ 34 36 \\ 35 33 \\ 36 37 \\ 36 35 \\ 36 38 \\ 37 35 \\ 38 5 \\ 38 37 \\ 39 32 \\ 39 30 \\ 40 34 \\ 40 39 \\ 41 39 \\ 41 28 \\ 42 41 \\ 42 24 \\ 42 22 \\ 43 38 \\ 43 40 \\ 44 41 \\ 44 42 \\ 44 49 \\ 44 51 \\ 45 6 \\ 45 3 \\ 46 14 \\ 46 12 \\ 46 48 \\ 47 18 \\ 47 16 \\ 48 10 \\ 48 45 \\ 48 50 \\ 49 45 \\ 49 43 \\ 49 40 \\ 50 47 \\ 50 46 \\ 50 51 \\ 51 20 \\ 51 47 \\ } % Angabe der Verbindungskanten ===================== ] table[header=true, x index=1, y index=2, row sep=\\] { Nr x y Textposition \\ 0 0 0 south \\ 1 -1.23 4.58 \\ 2 -2.01 3.95 \\ 3 -1.07 3.59 north \\ 4 -1.85 2.96 south \\ 5 -2.78 3.32 \\ 6 -0.97 3.62 \\ 7 -0.27 4.32 \\ 8 -0.01 3.36 \\ 9 0.70 4.06 \\ 10 0.96 3.10 \\ 11 1.67 3.81 \\ 12 1.34 2.86 \\ 13 2.32 3.05 \\ 14 1.99 2.10 \\ 15 2.97 2.29 \\ 16 2.04 1.93 north \\ 17 2.81 1.30 south \\ 18 1.88 0.95 \\ 19 2.66 0.31 \\ 20 1.66 0.43 \\ 21 2.06 -0.49 \\ 22 1.06 -0.37 \\ 23 1.46 -1.29 \\ 24 0.96 -0.42 north \\ 25 0.46 -1.28 south \\ 26 -0.04 -0.41 \\ 27 -0.54 -1.28 \\ 28 -1.04 -0.41 north \\ 29 -1.54 -1.27 south \\ 30 -1.16 -0.35 \\ 31 -2.15 -0.48 \\ 32 -1.77 0.44 \\ 33 -2.76 0.32 \\ 34 -1.90 0.82 \\ 35 -2.77 1.32 \\ 36 -1.90 1.82 \\ 37 -2.77 2.32 \\ 38 -1.91 2.82 north \\ 39 -0.77 0.57 south \\ 40 -1.16 1.50 \\ 41 -0.08 -0.14 \\ 42 0.66 0.54 north \\ 43 -0.97 2.48 south \\ 44 -0.30 0.83 \\ 45 -0.81 2.63 \\ 46 1.01 1.92 \\ 47 1.10 1.58 \\ 48 0.18 2.48 \\ 49 -0.21 1.83 \\ 50 0.11 1.48 \\ 51 0.69 0.67 \\ }; % Beschriftungen ============================ % Laut Handbuch "replicate the vertex list to show \coordindex" % Anzeigen des 0. Aliaspunktes verhindern: \newcommand\Punktnummer{\pgfmathparse{\punktnummer>0 ? \punktnummer : ""}\pgfmathresult} \addplot[ only marks, visualization depends on={value \thisrowno{0} \as \punktnummer}, visualization depends on={value \thisrowno{3} \as \Anker}, nodes near coords={\Punktnummer}, % every node near coord/.append style={ font=\scriptsize, %\sffamily text=black, anchor=\Anker }, ] table[header=true, x index=1, y index=2, row sep=\\] { Nr x y Textposition \\ 0 0 0 south \\ 1 -1.23 4.58 \\ 2 -2.01 3.95 \\ 3 -1.07 3.59 north \\ 4 -1.85 2.96 south \\ 5 -2.78 3.32 \\ 6 -0.97 3.62 \\ 7 -0.27 4.32 \\ 8 -0.01 3.36 \\ 9 0.70 4.06 \\ 10 0.96 3.10 \\ 11 1.67 3.81 \\ 12 1.34 2.86 \\ 13 2.32 3.05 \\ 14 1.99 2.10 \\ 15 2.97 2.29 \\ 16 2.04 1.93 north \\ 17 2.81 1.30 south \\ 18 1.88 0.95 \\ 19 2.66 0.31 \\ 20 1.66 0.43 \\ 21 2.06 -0.49 \\ 22 1.06 -0.37 \\ 23 1.46 -1.29 \\ 24 0.96 -0.42 north \\ 25 0.46 -1.28 south \\ 26 -0.04 -0.41 \\ 27 -0.54 -1.28 \\ 28 -1.04 -0.41 north \\ 29 -1.54 -1.27 south \\ 30 -1.16 -0.35 \\ 31 -2.15 -0.48 \\ 32 -1.77 0.44 \\ 33 -2.76 0.32 \\ 34 -1.90 0.82 \\ 35 -2.77 1.32 \\ 36 -1.90 1.82 \\ 37 -2.77 2.32 \\ 38 -1.91 2.82 north \\ 39 -0.77 0.57 south \\ 40 -1.16 1.50 \\ 41 -0.08 -0.14 \\ 42 0.66 0.54 north \\ 43 -0.97 2.48 south \\ 44 -0.30 0.83 \\ 45 -0.81 2.63 \\ 46 1.01 1.92 \\ 47 1.10 1.58 \\ 48 0.18 2.48 \\ 49 -0.21 1.83 \\ 50 0.11 1.48 \\ 51 0.69 0.67 \\ }; % Beschriftungen ============================ \end{axis} \end{tikzpicture} \end{document} [1]: https://texwelt.de/wissen/upfiles/Patch0b.png
Klicke auf Einblenden/Ausblenden von Überarbeitungen 4

29 Aug '18, 20:25

cis's gravatar image

cis
9.5k102460491

Klicke auf Einblenden/Ausblenden von Überarbeitungen 3

29 Aug '18, 20:22

cis's gravatar image

cis
9.5k102460491

Klicke auf Einblenden/Ausblenden von Überarbeitungen 2

29 Aug '18, 20:21

cis's gravatar image

cis
9.5k102460491

Klicke auf Einblenden/Ausblenden von Überarbeitungen 1

29 Aug '18, 20:20

cis's gravatar image

cis
9.5k102460491

Willkommen, erstes Mal hier? Schau mal unter FAQ!

×