This is a follow-up question to: Generalised: Accessing the logic values of a TikZ coordinate.
In that question a PGFplot answer was suggested by jake.
I took that answer and modified it to the following MWE:
\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{intersections}
\newcommand\xcoord[2][center]{{%
\pgfpointanchor{#2}{#1}%
\pgfgetlastxy{\ix}{\iy}%
\pgfplotspointaxisorigin%
\pgfgetlastxy{\ox}{\oy}
\pgfmathparse{(\ix-\ox)/\pgfplotsunitxlength/1000}
\pgfmathprintnumber{\pgfmathresult}}
}
\begin{document}
\vspace{1cm}
\begin{tikzpicture}
\begin{axis}[
domain=1:8.2,
samples=150,
no markers,
axis lines=middle,
enlarge x limits=upper,
enlarge y limits=true,
x axis line style={{name path global=xaxis}}
]
\addplot +[name path global=plot] {(x-2.07)*(x-4.09)*(x-5.72)*(x-8.04)};
\pgfplotsextra{
\fill [name intersections={of=xaxis and plot, name=i, total=\t}]
[red, every node/.style={black}]
(i-1) circle (2pt) node [pin={\xcoord{i-1}}] {}
(i-2) circle (2pt) node [pin={\xcoord{i-2}}] {};
}
\end{axis}
\end{tikzpicture}
\end{document}
This produces the following:

So the coordinates is off by a factor 10.
How would one correct that and I was wondering how one would access them through a foreach loop in stead of specifically making a node for each of them.
