Take the 2-minute tour ×
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.

Following example does not work:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\makeatletter
\begin{tikzpicture}
  \begin{axis}
    \addplot  coordinates {(948e-6,1.61981) (1.5e-3,1.02377) (2e-3,0.769047) (2.5e-3,0.614994) (3e-3,0.503511)};
    \node (A) at ({rel axis cs:0.25,0.25}) {\pgfkeysvalueof{/pgfplots/xmin}};
    \node (B) at ({rel axis cs:0.75,0.75}) {\pgfplots@data@xmin};
    \node (C) at ({rel axis cs:0.5,0.5}) {\pgfmathparse{min(\pgfplots@data@xmin,\pgfkeysvalueof{/pgfplots/xmin})} \pgfmathresult};
  \end{axis}
\end{tikzpicture}
\makeatother
\end{document}

Error message:

line 14 error| Package PGF Math Error: Unknown operator `Y' or `Y9' (in 'min(1Y9.48e-4],7.427876e-4)').

if I disable \node (C) it works.

I do not understand why the return value of \pgfplots@data@xmin looks so strange.

share|improve this question
    
It's the fpu representation of a number. Pgfplots use it by default but TikZ doesn't. –  percusse Jul 3 at 12:26

1 Answer 1

up vote 5 down vote accepted

As percusse said in the comment, that's the floating point representation that's used by PGFPlots. To make your code work, add \pgfkeys{/pgf/fpu} before the \pgfmathparse command to switch on the floating point math parser. To print the result using the conventional representation, either use \pgfmathprintnumber{\pgfmathresult} to format the number, or set \pgfkeys{/pgf/fpu=true, /pgf/fpu/output format=fixed} to use a fixed point output format.

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\makeatletter
\begin{tikzpicture}
  \begin{axis}
    \addplot  coordinates {(948e-6,1.61981) (1.5e-3,1.02377) (2e-3,0.769047) (2.5e-3,0.614994) (3e-3,0.503511)};
    \node (A) at ({rel axis cs:0.25,0.25}) {\pgfkeysvalueof{/pgfplots/xmin}};
    \node (B) at ({rel axis cs:0.75,0.75}) {\pgfplots@data@xmin};
    \node (C) at ({rel axis cs:0.5,0.5}) {
        \pgfkeys{/pgf/fpu=true}
        \pgfmathparse{min(\pgfplots@data@xmin,\pgfkeysvalueof{/pgfplots/xmin})}
        \pgfmathprintnumber{\pgfmathresult}
    };
  \end{axis}
\end{tikzpicture}
\makeatother
\end{document}
share|improve this answer
    
thank you very much. One minor question: how I can I format the node B to look identical to node C? –  Hotschke Jul 3 at 14:09
    
And if you know where I could have found this information in the pgf/tikz or pgfplots documentation, you could add the respective location in the docs to your answer. –  Hotschke Jul 3 at 14:11

Your Answer

 
discard

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.