I can't overcome this little nasty issue. Using \ifnum I set labels position around the coordinates in my pgfplot. This works fine but :
I am only able to test if variable \coordindex is greater or smaller than a certain value.
I want to be able to test if the index is equal to a number.
Tex gives me this error, in case I use \ifnum\coordindex=0 at first.
Missing = inserted for \ifnum. \end{axis}
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\pgfplotsset{
name nodes near coords/.style={
every node near coord/.append style={
anchor=center, %
name=#1\coordindex, % naming of npdes with running index
alias=#1last,
},
},
name nodes near coords/.default=coordnode
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=\textwidth,
height=.3\textheight,
scale mode = scale uniformly,
scale only axis,
xmin=-200,
xmax= 250,
ymin=- 50,
ymax= 400,
axis x line = middle,
axis y line = left,
grid = none,
xtick = {-200, -100, ...,300},
ytick = {-100, 0, ...,400},
minor tick num = 1,
ytick align = outside,
extra x ticks={0},
extra x tick style={grid=major},
xlabel={x / mm},
ylabel={y / mm},
]
\addplot+[
color=orange,
ultra thick,
shape=circle,
nodes near coords={},
every node near coord/.append style={
label={
[black!80, label distance=-1ex]
\ifnum\coordindex<1
5
\else
% \ifnum\coordindex=3
% -135
% \else
180-\coordindex*45
% \fi
\fi
:$p_{\coordindex}$
}
},
name nodes near coords=p
]
table{%
0 0
-79.9393 236.8749
143.0014 350.0007
143.0014 300.0000
200.0008 300.0000
};
\end{axis}
\end{tikzpicture}
\end{document}
I also tried with the ifthen package but had no luck. Please does anybody have a quick solution to this? What am I doing wrong? According to the document this shouldn't arise.
Maybe one of you also has a hint on how to print the ylabel the same way the xlabel is set; just at the top of and/or beside the y label.
\newcommand\equals{=}in the preamble and\ifnum\coordindex\equals 0should work. At least no error is raised. See http://tex.stackexchange.com/questions/214995/why-does-ifnum-not-work-inside-of-tikz-style-definitions – egreg Dec 18 '14 at 14:10