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 large
error, 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/fpu
to 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?",pgfplots
usesfpu
internally, 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:
\pgfmathadd
will be replaced with\pgfmathfloatadd
and so on. Furthermore, any number will be parsed with\pgfmathfloatparsenumber
. So, if I already have the FPU, maybe I need to use\pgfmathfloatmultiply
instead? 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\pgfmathmultiply
is 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}