# PGFPlots polaraxis axis labels are swapped (or in the wrong place)

I have some problems with axis labels when using the polar axis, if I set the X and Y label they appear in the wrong place.

When using the polar axis;

• x coordinate is the angle (azimuth, phi)
• y coordinate is the radius (zenith, theta).

However, the xlabel is printed where one would expect it to be in a cartesian plot, except that that is now the y axis (using TeXLive 2015, PGFPlots v1.12.1). Similar for the y label is is located where the y axis would be in a cartesian plot, except that is it rotated.

Here I used:

xlabel={Azimuth [rad] (x-label)},
xlabel style={red},
ylabel style={blue},


This is how it looks in TeXLive 2015, PGFPlots v1.12.1:

This is how it looks in TeXLive 2013/2014, PGFPlots v1.8/v1.10:

Using some shifts and rotations we get it to look nice, however, those shifts are different for TeXLive 2013-2014 and 2015:

This did require some ugly hacks, for the xlabel:

\coordinate (xlabel) at ([rotate=-45, yshift=1.5cm] xticklabel* cs: 0);
\node[rotate=-45] at (xlabel) { {{ xlabel }} };


The ylabel value is simply entered as xlabel and then shifted with the axis line, but that does not work for 2013/2014.

Should we resort to version detection to make it work in all versions? And will this be fixed in the next PGFPlots? (We created a Python package for plotting which outputs plots as TeX using PGFPlots, so compatibility with older versions would be nice.)

• This is a bug in pgfplots. I will take care of it. Jul 29, 2015 at 10:45
• Do you have a tip about how to handle it for v1.12 and earlier? Jul 29, 2015 at 13:18

The root cause is a bug in pgfplots: apparently, the ticklabel coordinate systems do not work as expected. This morning, I have managed to improve the polar library such that the default for pgfplots 1.13 will directly result in the label placement as in your screenshot. I will also simplify sloped tick labels and add some more fine tuning to it.

For the time being, you may want to replace your relative label placement by an absolute one, i.e. by something like

\documentclass{standalone}

\usepackage{pgfplots}

\pgfplotsset{compat=1.12}

\usepgfplotslibrary{polar}

\begin{document}
\pgfplotsset{
polar labels/.style={
every axis x label/.style={
at={(axis cs:45,\pgfkeysvalueof{/pgfplots/ymax}*1.3)},
anchor=center,
rotate=-45,
},
},
}

\begin{tikzpicture}
\begin{polaraxis}[
xlabel=x axis,
]

I have not provided a solution for the ylabel since you already appear to have that under control. My solution is to place it absolutely at 45 degrees and 130% of the y limit.