[Tex/LaTex] pgfplots: Scaling legend font size

pgfplotstikz-pgf

There are a few posts that ask and answer how to scale the legend font size. For example,

However, these rely upon using the command:

 legend style={font=\tiny}

I'd like to re-scale the legend fonts (or perhaps even the entire legend) using a scale = 0.5 command (or similar), similar to how you would re-scale a node. I asked a similar question here about re-scaling the font size of axes labels, but I could not get the same solution to work for the legend (that is, simply changing font= to style= does not seem to work.

I attach a minimal example below:

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[legend image post style={mark=*}]

\addplot+[mark=*, color=blue, very thin, only marks, mark size=0.8pt]{-x*(x-2)};
\addlegendentry{Measurement}
\end{axis}
\end{tikzpicture}

\end{document}

which produces

legend example

Best Answer

Something like:

[...]
    \begin{axis}[legend style={nodes={scale=0.5, transform shape}}, 
        legend image post style={mark=*}]
[...]

The "style" nodes of the legend will be applied to all the nodes created to generate the legend box.

Screenshot for the above snippet

(BTW, you should add a \pgfplotsset{compat=1.9} to your code, or at least something like that, to avoid problems with ticks labels in the future).

Complete code (for reference):

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[legend style={nodes={scale=0.5, transform shape}}, 
        legend image post style={mark=*}]

\addplot+[mark=*, color=blue, very thin, only marks, mark size=0.8pt]{-x*(x-2)};
\addlegendentry{Measurement}
\end{axis}
\end{tikzpicture}

\end{document}