[Tex/LaTex] PGFPlots: Make tick labels tiny

pgfplotstikz-pgf

I want to make the tick labels tiny in size. Additionally, I need to hide the z-axis. Finally, I would like to suppress the y-axis tick labels.

Update: Red was able to help with the tick label size, as well as correctly hiding the z-axis. Lastly, the ticks on the y-axis were suppressed. The complete solution is included in my code.

  1. Leave the z-axis in and the labels are too big. See the left image.
  2. Remove the z-axis and all labels go away, which is not what I need either. Also, two strange, short lines appear toward the top of the graph when I remove the z-axis. See the right image.

enter image description hereenter image description here

Here is an image of the correct solution. (Note: Made irrelevant adjustments to the square size.)

enter image description here

MWE:

\documentclass{memoir}
\usepackage{pgfplots}

\begin{document}

\pgfplotsset{
    compat=1.8, % Allows drawing of circles.
    standard/.style={
        axis line style=help lines,
        axis x line=center,
        axis y line=center,
        axis z line=center,
        xlabel={$x$},
        ylabel={$y$},
        zlabel={$z$},
    every axis/.append style={font=\tiny},  
}

{\centering
\begin{tikzpicture}[scale=1]

\begin{axis}[
    standard,
    hide z axis,
    xmin=-1.25, xmax=1.25,
    ymin=-1.25, ymax=1.25,
    zmin=0, zmax=2.5,
    xtick={-1,1},
    xticklabels={$-2r$,$2r$},
    ytick=\empty,
]
% Draw Square
    \draw[green]    (axis cs: -0.86602540378,0.5,0) --
                (axis cs: -0.86602540378,-0.5,0) --
                (axis cs: -0.86602540378,-0.5,1) --
                (axis cs: -0.86602540378,0.5,1) --
                (axis cs: -0.86602540378,0.5,0);
\draw[blue] (axis cs: 0,0,0)
    ellipse [
    x radius=1, y radius=1];

\end{axis}
\end{tikzpicture}
\vspace{0.5 cm}
}

\end{document}

Best Answer

You can add every axis/.append style={font=\tiny}, before every axis x label/.style. In this way you don't need to use \tiny in x-y-z-labels.

To hide z axis just add hide z axis, after axis z line=center. I believe that if you put only axis z line=none you are hiding only the axis line but not the ticks that are the short lines in your image. They are in that position because with axis z line=none the z-axis is no more centered.

\documentclass{memoir}
\usepackage{pgfplots}

\begin{document}

\pgfplotsset{
  compat=newest, % Allows drawing of circles.
  standard/.style={
    axis equal,
    axis line style=help lines,
    axis x line=center,
    axis y line=center,
    axis z line=center,
    hide z axis,
every axis/.append style={font=\tiny},
    every axis x label/.append style={
      at={(axis cs:\pgfkeysvalueof{/pgfplots/xmax},0,0)},xshift=0.5em},
    every axis y label/.append style={
      at={(axis cs:0,\pgfkeysvalueof{/pgfplots/ymax},0)},yshift=0.7em},
    every axis z label/.append style={
      at={(axis cs:0,0,\pgfkeysvalueof{/pgfplots/zmax})},xshift=0.5em}
  }
}

{\centering
\begin{tikzpicture}[scale=1]

\begin{axis}[
  standard,
  xmin=-1, xmax=1,
  ymin=-1, ymax=1,
  zmin=0, zmax=2,
  xtick={-1,1},
  xticklabels={$-2r$,$2r$},
  ytick={-1,1},
  yticklabels={$-2r$,$2r$},
  xlabel=$x$,
  ylabel=$y$,
  zlabel=$z$
]
% Draw Square
\draw[green]    (axis cs: -0.5,0.86602540378,0) --
        (axis cs: -0.5,-0.86602540378,0) --
        (axis cs: -0.5,-0.86602540378,1.73205080757) --
        (axis cs: -0.5,0.86602540378,1.73205080757) --
        (axis cs: -0.5,0.86602540378,0);
\draw[blue] (axis cs: 0,0,0)
  ellipse [
    x radius=1, y radius=1];

\end{axis}
\end{tikzpicture}
\vspace{0.5 cm}
}

\end{document}

Image with font=\tiny

enter image description here

Image without font=\tiny

enter image description here