# Distance of the axis labels Pgfplots

Why this options change the distance of the axis labels in this plot ?

 \pgfplotsset{/pgf/number format/use comma,compat=newest,%
width=12cm,%
height=9cm%
}


in this document:

\documentclass[a4paper,12pt]{article}
\usepackage{pgfplots,pgfplotstable}        % Grafici
width=12cm,%
height=9cm%
}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\makeatletter \newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis} \makeatother
\pgfplotsset{axis line on top/.style={
axis on top=false,
after end axis/.append code={
\pgfplotsset{axis line style=opaque,
ticklabel style=opaque,
tick style=opaque,
grid=none}
\pgfplotsdrawaxis}
}
}
\begin{axis}[/pgf/number format/fixed,
legend pos=outer north east,
grid=major,
xmin=0, xmax=0.2,
ymin=0, ymax=0.6,
point meta min={0},
point meta max={0.2},
yticklabel shift=2pt,
xticklabel shift=2pt,
legend pos=north west,
minor tick num=4,
axis line on top,
xticklabel style={text height=1.5ex},
xtick={0,0.05,...,0.3},
minor xtick={0,0.01,...,0.2},
extra x ticks={0,0.05,...,0.3},
extra x tick style={
xticklabel pos=right,
xticklabel style={text depth=0pt}
},
extra y ticks={0,0.1,...,0.7},
extra y tick style={
yticklabel pos=right
},
tick style={thin,black},
xlabel=\large $m$,
ylabel=\large $\Delta l$,
colorbar horizontal,
colorbar style={
/pgf/number format/fixed,
xticklabel shift=2pt,
xtick={0,0.05,...,0.3},
xticklabel style={text height=1.5ex}
},
colormap={new}{color(0cm)=(violet);color(1cm)=(blue);color(2cm)=(cyan);color(3cm)=(green);color(4cm)=(yellow);color(5cm)=(orange);color(6cm)=(red)},
after end axis/.append code={
\draw ({rel axis cs:0,0}-|{axis cs:0,0}) -- ({rel axis cs:0,1}-|{axis cs:0,0});
},
legend cell align=left]
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}


I have modified the distance of the of axis numbers from the grid and then I would return to normal distance between the numbers of the axis and the axis labels. Thanks

-
Please don't just post your complete code, but make a minimal example that shows the behaviour. Remove bits of the code until the error no longer appears. You don't need a regression, or real data, or two almost identical figures, or the color bar. –  Jake Jun 1 '12 at 9:37
sorry ! i have edited my question but i have leave the colorbar because i want to see the distance with the axis labels –  FormlessCloud Jun 1 '12 at 15:38
Sorry but I don't understand the question. Do you want to keep the axis numbers to stay close to the gridlines? Does it help if you change your x,y ticklabel shift to 1ex instead of 2pt? –  percusse Jun 1 '12 at 17:14
this command increases the distance of the numbers from the grid, but by increasing this distance decreases the distance between the numbers and labels of the axes ok? I would restore the original distance between the labels and numbers while maintaining the distance between the numbers and the grid yticklabel shift=2pt xticklabel shift=2pt –  FormlessCloud Jun 3 '12 at 14:57
The key compat=newest is supposed to change the way axis labels are placed.
Note that the use of compat=newest is generally discouraged. What should happen if version 1.7 wants to change default values? The choice newest would result in a different output compared to now. Please use compat=1.5 or compat=1.6 (or whatever version you are running). Since 1.6, pgfplots will dump a suggested value to the log file.
In your case, you can use the axis option xlabel absolute (or its y variant) to restore the old absolute placement.