[Tex/LaTex] pgfplots exponent in ylabel instead of yticklabel

pgfplots

I know there are already a lot of questions answered about the exponents of the ticklabels and how to get rid of them, but in my extensive search I was not able to find an answer to my specific question.
Take the following example:

\documentclass[crop,10pt]{standalone}
\usepackage[english]{babel}
\usepackage{pgfplots}

\usepackage[space-before-unit,range-units = repeat]{siunitx}

\begin{document}%
    \setlength{\linewidth}{246pt}%

        \begin{tikzpicture}
        \begin{axis}[
        width=\linewidth,
        ytick pos = left,
        xtick pos = left,
        enlargelimits=false,
        clip=false,
        axis on top,
        tick align = outside,
        yticklabel style={%
        /pgf/number format/fixed,
        /pgf/number format/precision=1,
        /pgf/number format/fixed zerofill
    },
        xlabel={length (\si{\meter})},
        ylabel={length (\si{\meter})},
]
        \addplot
        coordinates
        {(1,0.0005) (2,0.001)   (3,0.0015)};
        \end{axis}
        \end{tikzpicture}
\end{document}

The graph and the ticklabels look the way I want them to. The only thing I want to do now, is to get rid of the " *10^{-3} " above the y axis and (manualy) change the ylabel to milimeters. When I use the scaled ticks=false option, this will change the ticklabels again and I would have to display them as 0.0005, 0.0010 and 0.0015 instead of 0.5, 1.0 and 1.5 which looks ugly. So the question is: Is there a way to get rid of the exponent (not displaying it) without the ticklabels getting changed? (Of course any other solution would also be appreciated)
Thank you for your help,
John

Best Answer

This is exactly what the units library is for.

It allows you to specify the SI base unit for your axis (in this case y unit=m) and if you allow the library to change the base for the numbers (by setting change y base=true) you can specify an SI prefix that will be applied to the label and the numbers (by setting y SI prefix=milli).

The format of the unit in the label can be controlled using unit markings=parenthesis, for instance:

\documentclass[border=5mm]{standalone}
\usepackage[english]{babel}
\usepackage{pgfplots}
\usepgfplotslibrary{units}

\usepackage[space-before-unit,range-units = repeat]{siunitx}

\begin{document}%
    \setlength{\linewidth}{246pt}%

        \begin{tikzpicture}
        \begin{axis}[
        width=\linewidth,
        ytick pos = left,
        xtick pos = left,
        enlargelimits=false,
        clip=false,
        axis on top,
        tick align = outside,
        unit markings=parenthesis,
        y unit=m, change y base=true,  y SI prefix=milli,
        yticklabel style={%
        /pgf/number format/fixed,
        /pgf/number format/precision=1,
        /pgf/number format/fixed zerofill
        },
        xlabel={length (\si{\meter})},
        ylabel={length},
]
        \addplot
        coordinates
        {(1,0.0005) (2,0.001)   (3,0.0015)};
        \end{axis}
        \end{tikzpicture}
\end{document}