7

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}
0

1 Answer 1

7

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

9
  • Thanks. I was trying to figure out that minor issue as well. I didn't realize I needed the append.
    – JDG
    Commented Jul 4, 2013 at 10:34
  • 1
    @JDG if this answers your question please mark it as correct, thanks
    – Red
    Commented Jul 4, 2013 at 10:52
  • Thanks, but your solution does not answer the question. Your solution tightens up the formatting code for the axis labels x, y, z. My question has to do with the tick labels 2r, -2r.
    – JDG
    Commented Jul 4, 2013 at 11:01
  • 1
    @JDG no, the command I suggested applies to all the axis that is to both axis label and axis ticks. I added the example without this line. But now your question is more clear and I see that I answered only to the first point so you don't have to mark my answer as correct, sorry.
    – Red
    Commented Jul 4, 2013 at 11:06
  • 1
    @JDG You only need ytick=\empty, then it will also remove the tick labels too.
    – percusse
    Commented Jul 4, 2013 at 11:31

You must log in to answer this question.

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