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}
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?
[code]
\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}
[/code]