pgfplots Beschriftung einzelner Datenpunkte

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smilies
:D :) :( :o :shock: :? 8) :lol: :-x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smilies sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Wenn du eine Datei oder mehrere Dateien anhängen möchtest, gib die Details unten ein.

Ansicht erweitern Die letzten Beiträge des Themas: pgfplots Beschriftung einzelner Datenpunkte

von monchi » Do 26. Sep 2013, 14:27

Besten Dank!

von esdd » Do 26. Sep 2013, 10:42

Es liegt nicht an dem 'global', sondern irgendwie an der Reihenfolge der Zeichenschritte. Mit dem folgenden Code tritt das Problem nicht auf:
\documentclass{scrartcl} 
\usepackage{pgfplots,pgfplotstable,filecontents} 
\pgfplotsset{compat=1.8} 
\usetikzlibrary{intersections}

\begin{filecontents*}{table.csv} 
  X,Y,Z,Label,Alng 
  100,150,2001,0,90 
  400,390,2002,0,180 
  600,645,2003,0,90 
\end{filecontents*} 

\pgfkeys{/pgf/number format/set thousands separator={}}

\newcommand\Diagramm{%
  \begin{tikzpicture}[scale=1.4, transform shape] 
    \def\varXmax{700} 
    \def\varYmax{\varXmax} 
  %
    \begin{axis}[ 
      xlabel={$S_{x,theoretisch} [mm]$}, 
      ylabel={$S_{x,gemessen} [mm]$}, 
      xmin={0}, 
      ymin={0}, 
      xmax={\varXmax}, 
      ymax={\varYmax}, 
      minor tick num=1, 
      try min ticks=10,
      clip mode=individual
    ] 
  %
      \addplot[scatter,only marks, 
        visualization depends on={\thisrow{Label} \as \Lblswitch}, 
        visualization depends on={\thisrow{Alng} \as \Alingmnt}, 
        visualization depends on={value \thisrow{Z} \as \LblZ}, 
        nodes near coords={\pgfmathparse{\Lblswitch > 0 ? "Beschriftung\ (\LblZ )" : ""}\pgfmathresult}, 
        every node near coord/.style={anchor=\Alingmnt} 
        ] table [x=X,y=Y,col sep=comma] {table.csv}; 
  %
      \path[name path=axis1](rel axis cs:0,0)rectangle(rel axis cs:1,1);
      \addplot [gray, style=dashed, no marks, domain=0:\varXmax,name path global=pe1]{0.75*x};   % -25% 
      \node[name intersections={of=axis1 and pe1}, right] at (intersection-2){-25\%}; 
      \addplot [gray, style=dashed, no marks, domain=0:\varXmax]{x}; 
      \addplot [gray, style=dashed, no marks, domain=0:\varXmax,name path global=pe3]{1.25*x};   % +25%       
      \node[name intersections={of=axis1 and pe3}, above] at (intersection-2){+25\%}; 
    \end{axis} 
  \end{tikzpicture}%
}

\begin{document} 
\Diagramm

\Diagramm
\end{document} 
Gruß
Elke

von sudo » Do 26. Sep 2013, 08:06

Das ist ja gerade der Sinn von `name path global`, dass sie eben nicht beschränkt, sondern global sind. Für die beschränkten gibt es `name path` ohne `global`. Ohne mir jedoch das Beispiel von Elke wirklich angesehen zu haben, gehe ich aufgrund Elkes Kompetenz davon aus, dass es einen Grund dafür gab, `name path global` zu benutzen.

von monchi » Mi 25. Sep 2013, 22:41

ich habe mir sowas schon fast gedacht. gibt es eine Möglichkeit "name path global" mit beschränktem Gültigkeitsbereich zu setzen? Also so wie bei Variablen. Werden diese z.B. innerhalb von einer figure-Umgebung deklariert, gelten sie auch nur in dieser.

von esdd » Mi 25. Sep 2013, 16:28

Irgendwie kommt er da mit den name path global Bezeichnungen durcheinander. Wenn du für jedes Diagramm für diese Bezeichnungen andere Namen wählst, klappt es.
Gruß
Elke

von monchi » Mi 25. Sep 2013, 15:47

Funktioniert leider doch nicht 100%ig.
So lange ich nur ein Diagramm mit der Extrabeschriftung verwende ist alles gut. Sobald ich aber im Dokument mehrere habe ist die Beschriftung nur noch bei dem ersten korrerkt. Alle weiteren haben die "+25%" ca. am Ursprung des Diagramms stehen. Jmand eine idee?
\documentclass{scrartcl}
\usepackage{pgfplots,pgfplotstable,filecontents}
\pgfplotsset{compat=1.8}
\usetikzlibrary{intersections}

\begin{filecontents*}{table.csv}
 X,Y,Z,Label,Alng
 100,150,2001,0,90
 400,390,2002,0,180
 600,645,2003,0,90
\end{filecontents*}

\pgfkeys{/pgf/number format/set thousands separator={}}


\begin{document}

    \begin{tikzpicture}[scale=1.4, transform shape]
          \def\varXmax{700}
          \def\varYmax{\varXmax}
             
          \begin{axis}[
                   xlabel={$S_{x,theoretisch} [mm]$},
                   ylabel={$S_{x,gemessen} [mm]$},
                   xmin={0},
                   ymin={0},
                   xmax={\varXmax},
                   ymax={\varYmax},
                   minor tick num=1,
                   try min ticks=10,
                ]

                \addplot[scatter,only marks,
                   visualization depends on={\thisrow{Label} \as \Lblswitch},
                   visualization depends on={\thisrow{Alng} \as \Alingmnt},
                   visualization depends on={value \thisrow{Z} \as \LblZ},
                   nodes near coords={\pgfmathparse{\Lblswitch > 0 ? "Beschriftung\ (\LblZ )" : ""}\pgfmathresult},
                   every node near coord/.style={anchor=\Alingmnt}
                   ] table [x=X,y=Y,col sep=comma] {table.csv};
           
                \addplot [gray, style=dashed, no marks, domain=0:\varXmax,name path global=pe1]{0.75*x};   % -25%
                \addplot [gray, style=dashed, no marks, domain=0:\varXmax]{x};
                \addplot [gray, style=dashed, no marks, domain=0:\varXmax,name path global=pe3]{1.25*x};   % +25%      
                \path[red,name path global=axis1](rel axis cs:0,0)rectangle(rel axis cs:1,1);
          \end{axis}
          \node[name intersections={of=axis1 and pe1}, right] at (intersection-2){-25\%};
          \node[name intersections={of=axis1 and pe3}, above] at (intersection-2){+25\%};
    \end{tikzpicture}
		
		    
		\begin{tikzpicture}[scale=1.4, transform shape]
        \def\varXmax{700}
        \def\varYmax{\varXmax}
             
          \begin{axis}[
                   xlabel={$S_{x,theoretisch} [mm]$},
                   ylabel={$S_{x,gemessen} [mm]$},
                   xmin={0},
                   ymin={0},
                   xmax={\varXmax},
                   ymax={\varYmax},
                   minor tick num=1,
                   try min ticks=10,
                ]

                \addplot[scatter,only marks,
                   visualization depends on={\thisrow{Label} \as \Lblswitch},
                   visualization depends on={\thisrow{Alng} \as \Alingmnt},
                   visualization depends on={value \thisrow{Z} \as \LblZ},
                   nodes near coords={\pgfmathparse{\Lblswitch > 0 ? "Beschriftung\ (\LblZ )" : ""}\pgfmathresult},
                   every node near coord/.style={anchor=\Alingmnt}
                   ] table [x=X,y=Y,col sep=comma] {table.csv};
           
                \addplot [gray, style=dashed, no marks, domain=0:\varXmax,name path global=pe1]{0.75*x};   % -25%
                \addplot [gray, style=dashed, no marks, domain=0:\varXmax]{x};
                \addplot [gray, style=dashed, no marks, domain=0:\varXmax,name path global=pe3]{1.25*x};   % +25%      
                \path[red,name path global=axis1](rel axis cs:0,0)rectangle(rel axis cs:1,1);
          \end{axis}
          \node[name intersections={of=axis1 and pe1}, right] at (intersection-2){-25\%};
          \node[name intersections={of=axis1 and pe3}, above] at (intersection-2){+25\%};
    \end{tikzpicture}
\end{document}

von monchi » Di 17. Sep 2013, 18:46

funktioniert 1a!

Danke dir!

von esdd » So 15. Sep 2013, 21:24

Das geht mit der Option transform shape. Ergänze diese bei den einzelnen Noden:
\node[name intersections={of=axis1 and pe1}, right, transform shape] at (intersection-2){-25\%};
\node[name intersections={of=axis1 and pe3}, above, transform shape] at (intersection-2){+25\%}; 
oder, wenn das für alle Noden gelten soll, geht auch
\begin{tikzpicture}[scale=1.4, transform shape]
Gruß
Elke

von Gast123 » So 15. Sep 2013, 20:59

die "Beschriftungen der Intersections" wird leider nicht automatisch mit skaliert. Kann man die Schriftgröße irgendwie automatische auf die gleiche Größe wie die Achsenbeschriftung einstellen?

von monchi » So 15. Sep 2013, 20:47

Besten Dank!

Nach oben