3

I'm having some trouble with polar plots. I have to plot negative values, but without changing direction. I tried to set the ymin value to be negative, but it doesn't work.

\documentclass[10pt,border=10pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}

\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[
   xticklabel=$\pgfmathprintnumber{\tick}^\circ$,
   ymin=-10,
   xtick={0,30,...,330}]
\addplot table{
   0  -1 
   30 -2
   45 -3
   60 -4
   75 -5
   };
\end{polaraxis}
\end{tikzpicture}
\end{document}

Any suggestion? For clarity, this is what I expected. img

  • 1
    What exactly do you mean by "it doesn't work"? What result were you expecting? – Jake Nov 20 '13 at 10:33
  • It is working here. As you can see, the blue dots are printed on the third quadrant indicating the negative value, that is, the opposite direction to the angle. – Sigur Nov 20 '13 at 10:45
  • This is not possible. This is not polar coordinates. In polar coordinates, the real value indicates the distance from the origin of the system and the sign indicates if the point is on the same direction or not. – Sigur Nov 20 '13 at 10:50
  • Thanks for your comments. I know that this is not polar coordinates, but I'd like to know if there's a way to get this result. – bersanri Nov 20 '13 at 10:52
5

You can transform the coordinates into the positive domain using y coord trafo/.code=\pgfmathparse{#1+10} and correct the tick labels by setting y coord inv trafo/.code=\pgfmathparse{#1-10}:

\documentclass[10pt,border=10pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}

\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[
   xticklabel=$\pgfmathprintnumber{\tick}^\circ$,
   xtick={0,30,...,330},
   y coord trafo/.code=\pgfmathparse{#1+10},
   y coord inv trafo/.code=\pgfmathparse{#1-10}
]
\addplot table{
   0  -1 
   30 -2
   45 -3
   60 -4
   75 -5
   };
\end{polaraxis}
\end{tikzpicture}
\end{document}
  • 1
    Nice! The transformation on the values was made using only two commands. A kind of translation. – Sigur Nov 20 '13 at 11:03
2
\documentclass[10pt,border=10pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}

\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[
   xticklabel=$\pgfmathprintnumber{\tick}^\circ$,
   xtick={0,15,...,360},
   ytick={0,1,2,...,5}
   ]
\addplot table{
   0  -1 
   30 -2
   45 -3
   60 -4
   75 -5
   };
\addplot table{
      0  1 
      30 2
      45 3
      60 4
      75 5
      };
\end{polaraxis}
\end{tikzpicture}
\end{document}

enter image description here

To obtain the same points as you want you have to take the difference between the distances, that is, 10-r. See the result of

   \addplot table{
      0  9 
      30 8
      45 7
      60 6
      75 5
      };

enter image description here

But I don't know how to change the labels.

  • 1
    Thanks for your time, but I don't think that this solution is answering to my question. – bersanri Nov 20 '13 at 10:55
  • @bersanri, I edited. – Sigur Nov 20 '13 at 10:56
  • 3
    I don't think that changing the data can be considered a solution. You are changing the problem. :) Anyway, thanks for the effort. – bersanri Nov 20 '13 at 10:59
  • @bersanri, so please, edit your question. You don't want to plot negative values. You want only to change the labels on the horizontal axis. – Sigur Nov 20 '13 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.