# How to add labels to polar plot / polar comb in polaraxis and show FULL coordinates?

In pgfplots, I am trying to:

1. for a first figure:

• label 12 polar plots plotted on the bases of 12 tables (values given in cartesian coordinates) without showing a legend but adding a label directly on the different graphs without entering manually the coordinates of each nodes, (this for polar plots).
2. for a second figure:

• label each branch of a "polar comb" (for a same table of value this time, see picture below), in the middle of the branch, rotating with the branch, at the right coordinate
• plot not only the distance of each point (see picture below, above the asterisk) but also the angle with respect to the x axis.

For this second plot, here the latex code:

\begin{tikzpicture}

\begin{polaraxis}[nodes near coords, width=4\textwidth,
xmin=-1,xmax=45.01, ymin=12, ymax=15,
title=Displacement 12N,
grid=both,
minor x tick num={4},
minor y tick num={1},
legend entries={
$F=12N$,
},
legend style={
at={(0.5,-0.05)},
anchor=north,
%legend columns=4,
%cells={anchor=west},
rounded corners=2pt,
}]

\addplot+[polar comb ,data cs=cart, mark size=1, mark=asterisk] table {b20_h0.3_L50_mod2_F12_mod2.tex};

\node[label={\rotatebox{0}{\textcolor{blue}{$0^{\circ}$}}},mark=none,inner sep=0pt] at (axis cs:0,13) {};

\node[label={\rotatebox{2.5}{\textcolor{blue}{$1^{\circ}$}}},mark=none,inner sep=0pt] at (axis cs:2.5,13) {};

\node[label={\rotatebox{3.5}{\textcolor{blue}{$2^{\circ}$}}},mark=none,inner sep=0pt] at (axis cs:3.5,13) {};

\node[label={\rotatebox{4.4}{\textcolor{blue}{$3^{\circ}$}}},mark=none,inner sep=0pt] at (axis cs:4.4,13) {};

\node[label={\rotatebox{5.8}{\textcolor{blue}{$4^{\circ}$}}},mark=none,inner sep=0pt] at (axis cs:5.8,13) {};

%etc.... many times

\end{polaraxis}
\end{tikzpicture}

Here an illustration of what the polar comb plot looks like with manual labelling (long...) and with the missing angle coordinate (only the distances..).

After using Jake's code with working example, here the result in my code as a copy:

Following Jake's remark, I put the code with the bugs here and some values to manipulate, I have the feeling it is related to the cartesian-polar conversion

\centering
\begin{tikzpicture}
\begin{polaraxis}[
visualization depends on=rawx \as \pgfplotspointrawx,
nodes near coords,
every node near coord/.style={
rotate=\pgfplotspointrawx,
append after command={
node [
anchor=south,
rotate=\pgfplotspointrawx,
shift={(axis direction cs:0,(12.75-\pgfplotspointmeta))}
] {$\pgfmathprintnumber{\pgfplotspointrawx}^\circ$}
}
},
width=4\textwidth,
xmin=0,xmax=45.01, ymin=12, ymax=15,
title=Displacement 12N,
grid=both,
minor x tick num={4},
minor y tick num={1},
legend entries={
$F=12N$,
},
legend style={
at={(0.5,-0.05)},
anchor=north,
rounded corners=2pt,
}]
\addplot+[polar comb ,data cs=cart, mark size=1, mark=asterisk] table {
13.8893888888889    0
13.8875152609215    0.256057893044211
13.8818942709919    0.512013162090311
13.8725256030249    0.767763280177719
13.8594087369111    1.02320591422122
13.8425429585071    1.27823902144993
13.8219273735841    1.53276094524909
%etc...
};

\end{polaraxis}
\end{tikzpicture}

Thank you very much in advance

-
Welcome to TeX.SX! It's not necessary to sign your questions (as there is already a box with your username below it). – Claudio Fiandrino Aug 3 '14 at 9:04
Hi Willi, welcome to the site! It's best if you only ask one question per post: that makes it easier for others with similar problems to find the question. Could you start a new question for the first part of your post? It would be good if you could include some more details and sample data, the question isn't really clear at the moment. – Jake Aug 3 '14 at 9:53
Hi @ClaudioFiandrino and Jake, thank you very much for the formatting and advises. Sorry that it was not well formatted but I am new her as you noticed. I will try next time to split the different questions. I thought they were related as my both problems occur with polaraxis "environment". Thank you very much! – Willi Aug 3 '14 at 11:13

For the rotation of the labels, you can use

visualization depends on = x \as \pgfplotspointx,
every node near coord/.style={
rotate = \pgfplotspointx
}

This makes the value of the x coordinates available in a macro called \pgfplotspointx, which is then used for the rotation.

To add the labels for the angle along the comb, you can use

every node near coord/.style={
append after command={
node [
anchor = south,
rotate = \pgfplotspointx,
shift = {(axis direction cs:0,(12.75-\pgfplotspointmeta))}
] {$\pgfmathprintnumber{\pgfplotspointx}^\circ$}
}
}

The key append after command is used to append TikZ code after the "normal" label node, which we use to generate another node. The line shift = {(axis direction cs:0,(12.75-\pgfplotspointmeta))} shifts the label to the radial position 12.75.

\documentclass[border=5mm]{standalone}

\usepackage{pgfplots}
\usepgfplotslibrary{polar}

\begin{document}

\begin{tikzpicture}

\begin{polaraxis}[
visualization depends on=x \as \pgfplotspointx,
nodes near coords,
every node near coord/.style={
rotate=\pgfplotspointx,
append after command={
node [
anchor=south,
rotate=\pgfplotspointx,
shift={(axis direction cs:0,(12.75-\pgfplotspointmeta))}
] {$\pgfmathprintnumber{\pgfplotspointx}^\circ$}
}
},
width=4\textwidth,
xmin=-1,xmax=45.01, ymin=12, ymax=15,
title=Displacement 12N,
grid=both,
minor x tick num={4},
minor y tick num={1},
legend entries={
$F=12N$,
},
yticklabel style={anchor=north}
]

\addplot+[polar comb, mark size=1, mark=asterisk] table {
0 13.7
5 13.8
15 14.6
36 13.9
};

\end{polaraxis}
\end{tikzpicture}

\end{document}
-
Hi again @Jake. Thank you very much for your very very fast answer! I will try this immediately :-) – Willi Aug 3 '14 at 11:20
Hi Jake, as I had a compilation error I tried your example and got the same following message: "Package PGF Math Error: Could not parse input '(12.75-1Y1.37 e1]' as a floating point number, sorry. The unreadable part was near '(12.75-1Y 1.37e1]'.." Do you have the same problem? I am wondering what the "1Y" is doing in front of the value? Is it a sort of label to indicate that's the first value in the Y column or something like that? Maybe this has to be removed in order to perform the subtraction. Thank you very much for your example it helps anyway to understand this code ;-) – Willi Aug 3 '14 at 11:46
@Willi: The 1Y is from the floating point maths unit that's used by PGFPlots: the number 13.7 would be represented internally as 1Y1.37e1. It seems you're using an older version of PGFPlots than me: in older versions of PGFPlots, floating point numbers weren't parsed in all contexts. Can you upgrade to the newest PGFPlots version? If not, let me know and I'll edit my answer with a workaround. – Jake Aug 3 '14 at 11:49
Ok, I will look around how to update pgfplot and try again. I will let you know. Thank you again!! – Willi Aug 3 '14 at 11:52
I updated with pain the pgfplots package. Now your example work well but when I put it in my script it does something else. I would like to add a screenshot but I don't see where I can do this here ... To describe shortly: the rotation with respect to \pgfplotspointrawx and the labels are wrong, in addition there are more label than branches... weird... by the way, what does \pgfmathprintnumber{\pgfplotspointrawx} this mean? Thank you in advance. – Willi Aug 3 '14 at 14:13