[Tex/LaTex] How to change the font size of the labels along the axes in pgfplots [using scaling]

pgfplotstikz-pgf

This is a continuation of a question that was asked and 'answered' here:

The suggested answers all involved using LaTeX's built-in font controls to adjust using, e.g. \tiny, \footnotesize, and so forth. Rather than using these inflexible commands, is there a way to use TikZ's scaling option? For instance, I'd like to do scale=0.5 and automatically cut the axis label to 50% as large.

The scale option gives a convenient way of scaling text within a tikzpicture environment. Is there a way to easily extend this to axis labels as well?

Best Answer

Directly scaling a font is not always the best alternative since either the font might turn out to be "too thick" if scaling up by a large factor, or "too thin", if scaling down; the font switches are the right way to change font sizes. That being said, as percusse mentioned in his comment, you can use the scale=<factor> option instead of font in the same style used in the linked answer:

every tick label/.append style={scale=0.5}

A complete example:

\documentclass{standalone}
\usepackage{pgfplots}

\pgfplotsset{
every tick label/.append style={scale=0.5},
every axis/.append style={
  axis x line=middle,    % put the x axis in the middle
  axis y line=middle,    % put the y axis in the middle
  axis line style={<->,color=blue}, % arrows on the axis
  xlabel={$x$},          % default put x on x-axis
  ylabel={$y$},          % default put y on y-axis
  }
}

\begin{document}

\newcommand\aea{4}%%
\newcommand\aer{%%
  (3* \aea * sin(x) * cos(x))/((sin(x))^3+(cos(x))^3)}%%
\newcommand\aex{\aer*cos(x)}%%
\newcommand\aey{\aer*sin(x)}%%


\begin{tikzpicture}
    \begin{axis}[
            xmin=-7,xmax=7,
            ymin=-7,ymax=7,
            grid=both,
            xtick={-6,-5,...,5,6},
            ytick={-6,-5,...,5,6},
            ]
            \addplot [domain=0:90,samples=100,blue]({\aex},{\aey}); 
            \addplot [domain=136:180,samples=100,red]({\aex},{\aey}); 
            \addplot [domain=90:134,samples=100,green]({\aex},{\aey}); 
            %% the asymptote:
            \addplot [domain=-8:8,samples=10,dashed,blue]({x},{-x-\aea});
    \end{axis}
\end{tikzpicture}

\end{document}

enter image description here