TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Yes this is known and there is not much you can do about it. – percusse Aug 6 '14 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 '14 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 '14 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 '14 at 14:30
up vote 4 down vote accepted

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).

share|improve this answer
OK. Thank you for your fast answer. I leave it like this (no bug report). – Willi Aug 6 '14 at 14:33
Solution has been integrated and will become part of pgfplots 1.12 . – Christian Feuersänger Dec 30 '14 at 15:53
Hi, great! Thank you! – Willi Dec 31 '14 at 17:16

A solution with PSTricks. Run it with xelatex:




enter image description here

share|improve this answer
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 '14 at 19:49
Yes, it does all calculations with PostScript, a complete programming language. – Herbert Aug 6 '14 at 19:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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