I noticed that for values close to 0° and 180° the angular values dramatically changes if the values are imported from cartesian data. Here the code (with cartesian coordinates plotted in polar with data cs=cart and the same coordinates in polar coordinates obtained with arctan2 Matlab function) and illustration:



    visualization depends on=x \as \pgfplotspointx,
    nodes near coords,
    every node near coord/.style={
        append after command={
            node [
                shift={(axis direction cs:0,(12.75-\pgfplotspointmeta))}
            ] {$\pgfmathprintnumber{\pgfplotspointx}^\circ$}
xmin=-2,xmax=1, ymin=12, ymax=16,
title=artctan2 precision problem,
minor x tick num={4}, 
minor y tick num={1},
\addplot+[polar comb, data cs=cart, mark size=1, mark=asterisk, color=blue, dashed] table {
14.370195   -0.304948
14.370195   -0.304948

\addplot+[polar comb, mark size=1, mark=asterisk, color=green, solid] table {-1.215683667   14.37343027
-1.215683667    14.37343027


enter image description here

Has anyone meet this issue?

Thank you in advance.

  • Yes this is known and there is not much you can do about it.
    – percusse
    Aug 6, 2014 at 13:49
  • @percusse: Hm, but \pgfmathparse{atan2(14.37,-0.304948)} \pgfmathresult gives the (almost) correct result of -1.20. Maybe there's something else at play in the conversion from cartesian to polar coordinates in PGFPlots?
    – Jake
    Aug 6, 2014 at 13:52
  • @Jake The conversion doesn't use it I think. I had a similar problem before and I guess we need to dive into polar code. Maybe I should say not much without hacking into the code. I think somewhere in the drawing fpu is turned off.
    – percusse
    Aug 6, 2014 at 13:57
  • Thank you for your fast comments. Thus, I will directly manipulate polar coordinates instead of using data cs =cart.
    – Willi
    Aug 6, 2014 at 14:30

2 Answers 2


This needs to be repaired in pgfplots, I accept this question as bug report.


The routine pgfplotsmathcarttopol does not make use of atan2 - instead, it computes the angle "manually", apparently with less precision.



angle = \angle; radius = \radius

to see that this is, indeed, the root cause.

Steps to be done would be to write an implementation (or adapter) for atan2 for the floating point unit of PGF and to use that one in pgfplotsmathcarttopol.

I will take a note for the todo list of pgfplots (no need to file a separate bug report).

  • OK. Thank you for your fast answer. I leave it like this (no bug report).
    – Willi
    Aug 6, 2014 at 14:33
  • Solution has been integrated and will become part of pgfplots 1.12 . Dec 30, 2014 at 15:53

A solution with PSTricks. Run it with xelatex:




enter image description here

  • Thank you for your answer! It seems to be a complete different package no? I am actually a new user of pgfplots so maybe I don't got all the tricks now! I will study your approach ;-)
    – Willi
    Aug 6, 2014 at 19:49
  • Yes, it does all calculations with PostScript, a complete programming language.
    – user2478
    Aug 6, 2014 at 19:51

You must log in to answer this question.

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