I'm trying to multiply some numbers that will end up in the legend of a plot. I can't get it to work:
If I naively try
\pgfmathmultiply, I get adimension too largeerror, with the code in MWE 1 (see below). I understand this is because TeX doesn't count beyond 18 inch (or so). All right, I need to loadfpu, as explained in section 36 of thepgfmanual(version 2.10).If I pass
/pgf/fputo an axis-environment, compilation fails withIllegal unit of measure (pt inserted)(with MWE 2). Even if the axis-environment is completely empty. According to " How do I use pgfmathdeclarefunction to create define a new pgf function?",pgfplotsusesfpuinternally, so I don't really understand why I can't load it.Maybe I'm using a wrong function, I thought. On page 362 of the PGF-manual, I read The installation exchanges any routines of the standard math parser with those of the FPU:
\pgfmathaddwill be replaced with\pgfmathfloataddand so on. Furthermore, any number will be parsed with\pgfmathfloatparsenumber. So, if I already have the FPU, maybe I need to use\pgfmathfloatmultiplyinstead? I tried with MWE 3, but this time it fails to compile with: ! Package PGF Math Error: Sorry, an internal routine of the floating point unit got an ill-formatted floating point number '1000'. The unreadable part was near '1000'... Maybe\pgfmathmultiplyis not meant to be used by the user, or so.
How do I multiply large numbers and show the result in my pgfplot?
Related yet different questions:
- How do I use pgfmathdeclarefunction to create define a new pgf function?
- How can I avoid the "Dimension too large" error when plotting in newer PGF versions?
- Dimension too large while plotting with pgfplots
MWE 1:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title={\pgfmathmultiply{1000}{1000}}
]
\addplot coordinates {(0, 0) (1, 1) (2, 2)};
\end{axis}
\end{tikzpicture}
\end{document}
MWE 2
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
\begin{tikzpicture}
\begin{axis}[/pgf/fpu,
title={\pgfmathmultiply{1000}{1000}}
]
\addplot coordinates {(0, 0) (1, 1) (2, 2)};
\end{axis}
\end{tikzpicture}
\end{document}
MWE 3:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title={\pgfmathfloatmultiply{1000}{1000}}
]
\addplot coordinates {(0, 0) (1, 1) (2, 2)};
\end{axis}
\end{tikzpicture}
\end{document}

\pgfmathparsein pgfplots now contains at least some hints and an example. – Christian Feuersänger Nov 26 '11 at 22:11fpuTikZ library is not loaded at all, the line\pgfkeys{/pgf/fpu=false}might throw an error, refer to https://tex.stackexchange.com/questions/496750/how-to-make-a-tikz-picture-coexist-with-the-fpu-library#comment1254186_496755. – user202729 Nov 23 '22 at 03:05