6

I pieced together a PGFplots file. It worked 16 out of 18 times. The two times it didn't work the input files were very similar to the ones that worked.

Error:

! Dimension too large.
<recently read> \pgfmath@x

I tried this solution, and the errors became

! Package PGF Math Error: Sorry, an internal routine of the floating point unit
got an ill-formatted floating point number `0.0'. The unreadable part was near
'0.0'..

and

! Illegal unit of measure (pt inserted).
<to be read again>

I also tried tinkering with the decimal places in the input file and the number in precision=3,. What's going on? The numbers in the input are seemingly too much for TeX to handle but the other files are similar and had no problems.

The .tex file

\documentclass[tikz]{standalone}

\usepackage{pgfplots}

%\usetikzlibrary{fpu}
%\pgfkeys{/pgf/fpu=true, /pgf/fpu/output format=fixed}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    y tick label style={
        /pgf/number format/.cd,
        fixed,
        fixed zerofill,
        precision=3,
        /tikz/.cd
    },
]
\addplot table[domain=0:360] {pgf-test-631.dat};
\end{axis}
\end{tikzpicture}
\end{document}

The data file

 000.0000000000   -5217.8683723600
 015.0000000000   -5217.8697310100
 030.0000000000   -5217.8734062100
 045.0000000000   -5217.8780573800
 060.0000000000   -5217.8817718100
 075.0000000000   -5217.8830629100
 090.0000000000   -5217.8817385100
 105.0000000000   -5217.8788803300
 120.0000000000   -5217.8769672400
 135.0000000000   -5217.8778445600
 150.0000000000   -5217.8811590700
 165.0000000000   -5217.8849278400
 180.0000000000   -5217.8866359200
 195.0000000000   -5217.8849276900
 210.0000000000   -5217.8811588800
 225.0000000000   -5217.8778444900
 240.0000000000   -5217.8769672200
 255.0000000000   -5217.8788803500
 270.0000000000   -5217.8817385800
 285.0000000000   -5217.8830622800
 300.0000000000   -5217.8817716900
 315.0000000000   -5217.8780572800
 330.0000000000   -5217.8734060900
 345.0000000000   -5217.8697309200
 360.0000000000   -5217.8683723600
2
  • 1
    It is because of the small variation in the numbers in the second column. Replacing 5217 in your data by 0 results in a correct compilation. See section 2.6.2 Dimension Too Large Errors in the pgfplots manual. May 29, 2017 at 6:28
  • 1
    Using \addplot table[domain=0:360,y expr=\thisrowno{1}+5217] gives you a plot, but the y tick labels are near to meaningless. May 29, 2017 at 6:46

1 Answer 1

7

The problem is the small variation in the numbers in the second column of data, they are all -5217.8..... This gives pgfplots problems computing the yticks. The pgfplots manual states that there is little you can do about this, but that is not true in your case. One way, is to read the data in shifted by 5217 and the adjust the labels afterwards.

Sample output

\documentclass[tikz]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=1.14}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[yticklabel={\pgfmathparse{\tick-5217}%
    $\pgfmathprintnumber[precision=3,zerofill]{\pgfmathresult}$}]
    \addplot table[domain=0:360,y expr=\thisrowno{1}+5217]
    {pgf-test-631.dat};
\end{axis}
\end{tikzpicture}
\end{document}

The data shifting is done by specifying that the y values should be taken from the second element of each row, and then add 5217:

y expr=\thisrowno{1}+5217

in the addplot table argument. The argument to \thisrowno to grad entry number 2 is the value 1 as the columns are zero indexed by default.

The label printing is then done by taking the tick value, subtracting 5217, and then printing with the desired number formatting

yticklabel={\pgfmathparse{\tick-5217}%
        $\pgfmathprintnumber[precision=3,zerofill]{\pgfmathresult}$}]

It is important that you remove other options that affect the setting of this label.

2
  • It works now but I had to use compat=1.13 instead of compat=1.14.
    – Kurzd
    May 29, 2017 at 7:09
  • That reflects your pgfplots version. I would suggest you update to the newest one. May 29, 2017 at 7:47

You must log in to answer this question.

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