0

I'm trying to draw a simple graph using tikz datavisualisation but I run into a "Dimension too large".

\documentclass[a4paper,10pt]{book}

\usepackage{tikz} \usetikzlibrary{datavisualization.formats.functions}

\begin{document}

 \tikz \datavisualization [scientific axes=clean, visualize as smooth line]
   data [format=function] {
     var x : interval [1338:5500] samples 100;
     func y =  (1000000 / \value{x} - 28 - 137.4) * 64 * 1.25;
   };

\end{document}

Any idea on how I can fix this ?

  • Hello. can you please provide a fully compilable example so we can run it on our PCs? thank you – anis Jun 26 '23 at 11:38
  • It appears to me that there is a negative value overflow. check this answer:

    https://tex.stackexchange.com/questions/350016/how-to-draw-a-hysteresis-loop-with-tikz-datavisualization

    and this one

    https://tex.stackexchange.com/questions/354071/dimension-too-large-errors-by-tikz-datavisualization

    My guess is that when x be is small enough, the negative value is really big and causes an overflow.

    – anis Jun 26 '23 at 11:46
  • 2
    See https://tex.stackexchange.com/a/518311. –  Jun 26 '23 at 11:53

2 Answers2

2

Literally copied from tex.stackexchange.com/a/518311.

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{datavisualization.formats.functions}
\newcommand{\pgfmathparseFPU}[1]{\begingroup%
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathparse{#1}%
\pgfmathsmuggle\pgfmathresult\endgroup}
\begin{document}
\begin{tikzpicture}
    \datavisualization [scientific axes=clean, visualize as smooth line,
    /pgf/data/evaluator=\pgfmathparseFPU]
data [format=function] {
  var x : interval [1338:5500] samples 100;
  func y =  (1000000 / \value{x} - 28 - 137.4) * 64 * 1.25;
};
\end{tikzpicture}
\end{document}

enter image description here

0

Here is an alternative with pgfplots

\documentclass[a4paper]{article}

\usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[ domain =1338:5000, samples=100, ] \addplot[smooth] {1000000 / x - 28 - 137.4) * 64 * 1.25}; \end{axis} \end{tikzpicture} \end{document}

anis
  • 1,510
  • 5
  • 13