8

I want to overlay Cartesian axes on a polar plot. The vertical axis sits on top of the polar radial (horizontal) tick label. How can I move the tick label(s) so they are below the horizontal axis or otherwise out of the way?

Notice "t" axis overlaying "0"

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.polar} 

\begin{document}
\begin{tikzpicture}
  \begin{polaraxis}[axis on top, xticklabel=$\pgfmathprintnumber{\tick}^\circ$]
    \addplot[fill=green!40,draw=none,domain=-60:60]{1};
    \coordinate (origin) at (axis cs:0,0);
  \end{polaraxis}
  \draw[thick,blue,-stealth] (origin) -- +(0,1) node [above right] {$t$};
  \draw[thick,blue,-stealth] (origin) -- +(1,0) node [midway, above] {$s$};
\end{tikzpicture}
\end{document}

1 Answer 1

5

You can change the alignment of the tick marks by setting ytick align=outside, and adjust the position of the tick labels by setting yticklabel style={ anchor=north, yshift=-2*\pgfkeysvalueof{/pgfplots/major tick length} }:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.polar} 

\begin{document}
\begin{tikzpicture}
  \begin{polaraxis}[
    axis on top,
    xticklabel=$\pgfmathprintnumber{\tick}^\circ$,
    ytick align=outside,
    yticklabel style={
        anchor=north,
        yshift=-2*\pgfkeysvalueof{/pgfplots/major tick length}
    }
    ]
    \addplot[fill=green!40,draw=none,domain=-60:60]{1};
    \coordinate (origin) at (axis cs:0,0);
  \end{polaraxis}
  \draw[thick,blue,-stealth] (origin) -- +(0,1) node [above right] {$t$};
  \draw[thick,blue,-stealth] (origin) -- +(1,0) node [midway, above] {$s$};
\end{tikzpicture}
\end{document}
5
  • I can't get this to work. If I do this in my full paper, I get an error ! Undefined control sequence. \pgfmath@dimen@ ...men@@ #1=0.0pt\relax \pgfmath@ (I see the \makeatletter but it doesn't seem to matter where I put that or if it's not there at all); if I LaTeX either of the MWE files here (including the one I was able to LaTeX a few days ago that I posted) I get ! Package PGF Math Error: You've asked me to divide 195.0' by 0.0', but I can not divide any number by 0.0'.` I have not updated texlive or any TeX packages since I posted this question.
    – Liam
    Commented Jan 14, 2014 at 21:00
  • @Liam: Sorry, the \makeatletter wasn't supposed to be there. So just by introducing ytick align=outside, yticklabel style={ anchor=north, yshift=-2*\pgfkeysvalueof{/pgfplots/major tick length} }, you introduce the error? That's really strange. What version of PGFPlots are you using?
    – Jake
    Commented Jan 14, 2014 at 21:09
  • Actually, it's just the yshift=... part; it works OK with ytick align only (but of course doesn't look right). My pgfplots version is cc2f2d2dbac8 Tagged version 1.5. I don't use anything newer because I can't find anything that works (I get an error about undefined control sequence \pgfplotsversiondate).
    – Liam
    Commented Jan 14, 2014 at 21:28
  • Can you try using yshift=-0.3cm (that corresponds to the default value of major tick length)?
    – Jake
    Commented Jan 14, 2014 at 21:31
  • Yes, that works.
    – Liam
    Commented Jan 14, 2014 at 21:36

You must log in to answer this question.

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