5

I would like to draw arrows with polar axis notation in a pgfplots figure that has Cartesian axes with the draw command:

\draw[->] (polar axis cs:radius=1, angle=30) -- (polar axis cs:radius=2, angle=30);

I could not find any way to do something like this in the documentation. Are polar coordinates supported in the axis environment?

3
  • What should be the reference point (origin) for this notation axis cs:0,0 ?
    – percusse
    Commented Aug 23, 2013 at 16:25
  • @percusse yes, I would like to define the coordinates with respect to axis cs:0,0
    – gypaetus
    Commented Aug 23, 2013 at 16:29
  • 1
    Could you provide a M(N)WE and specify what output you would like to have? Commented Dec 4, 2015 at 15:42

1 Answer 1

4

As a simple workaround you could calculate the coordinates with a bit of trigonometry, which can be put in a macro. Note that with compat=1.11 or newer axis cs is the default coordinate system. If you have compat=1.10 or older you need to use (axis cs:\rtheta{1}{30}).

\documentclass[border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\newcommand\rtheta[2]{{#1*cos(#2)},{#1*sin(#2)}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,ymin=-1,ymax=1,xmin=-1,xmax=1]
\draw (\rtheta{0}{0}) -- (\rtheta{1}{30}) -- (\rtheta{1}{120});
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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