3

I've drawn a quarter-circle polar axis with pgfplots. However, the ticks are drawn on the 90-degrees axis whereas the tick labels are drawn on the 0-degrees axis. Can I fix this with pgfplots options?

In this picture, I've circled the ticks and drawn lines where I'd like them to be instead:

enter image description here

Code used to produce the above:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots,pgfplotstable}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{polar}

\begin{document}
\begin{tikzpicture}
  \begin{polaraxis}[
    width=10cm,
    height=10cm,
    grid=both,
    grid style={dotted},
    xmax=90,
    ymax=7,
    ylabel=y label,
    ylabel style={yshift=-5mm, anchor=north},
    xtick={0,22.5,45,67.5,90},
    xticklabels={0$^\circ$,,45$^\circ$,,90$^\circ$},
  ]
  \end{polaraxis}
\end{tikzpicture}
\end{document}

1 Answer 1

2

I have not found anything in the chapter on polar in the documentation. There seems to be the problem with 5.10.6 "Partial Polar Axes" as well (see image below).

enter image description here

But, after looking into the code, I found the option ytick pos=left, that gives the desired result.

Variant 1

Code

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots,pgfplotstable}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{polar}

\begin{document}
\begin{tikzpicture}
    \begin{polaraxis}[
        width=10cm,
        height=10cm,
        grid=both,
        grid style={dotted},
        xmin=0,
        xmax=90,
        ymax=7,
        ylabel=y label,
        ylabel style={yshift=-6mm, anchor=north},
        xtick={0,22.5,45,67.5,90},
        xticklabels={0$^\circ$,,45$^\circ$,,90$^\circ$},
        ytick pos=left,
    ]
    \end{polaraxis}
\end{tikzpicture}
\end{document}

Result

enter image description here

Variant 2

Using some code of this answer you could also put the numbers outside.

yticklabel style={
    anchor=north,
    yshift=-\pgfkeysvalueof{/pgfplots/major tick length}
},

Result

enter image description here

1
  • Thank you very much!
    – Anna
    Aug 28 at 13:02

You must log in to answer this question.

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