54

Surely this question must have been asked before, but I cannot find it and my searches through the user's guide are proving fruitless.

I have the following graph:

% arara: pdflatex
% arara: pdflatex
% arara: open
\documentclass{standalone}
\usepackage{pgfplots}

\pgfplotsset{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}

I would like to change the size of the fonts along the axes so that the numbers don't overlap each other (yes I want all those numbers there!).

enter image description here

2 Answers 2

51

You can use to adjust the style to the tick labels:

\pgfplotsset{every tick label/.append style={font=\tiny}}

enter image description here

If you want to also shift the tick labels closer to the axis you can use:

\pgfplotsset{every x tick label/.append style={font=\tiny, yshift=0.5ex}}
\pgfplotsset{every y tick label/.append style={font=\tiny, xshift=0.5ex}}

enter image description here

2
  • And if I wanted to position those labels closer to the axes, would you have any suggestions?
    – A.Ellett
    Commented Oct 15, 2014 at 2:33
  • Updated answer posted. Commented Oct 15, 2014 at 2:36
52

You can also use ticklabel style = {font=\tiny} in the axis options or \pgfplotsset.

enter image description here

If you want separate styles, you can use

        yticklabel style = {font=\tiny,xshift=0.5ex},
        xticklabel style = {font=\tiny,yshift=0.5ex}

Full code:

% arara: pdflatex
% arara: pdflatex
% arara: open
\documentclass{standalone}
\usepackage{pgfplots}

\pgfplotsset{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},
            yticklabel style = {font=\tiny,xshift=0.5ex},
            xticklabel style = {font=\tiny,yshift=0.5ex}
            ]
            \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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .