pgf-tikz / pgfplots

pgfplots - A TeX package to draw normal and/or logarithmic plots directly in TeX in two and three dimensions with a user-friendly interface and pgfplotstable - a TeX package to round and format numerical tables. Examples in manuals and/or on web site.
http://pgfplots.sourceforge.net/
190 stars 34 forks source link

`scatter/@pre marker code` uses wrong transformation #483

Open schtandard opened 4 weeks ago

schtandard commented 4 weeks ago

According to the documentation, the coordinate system inside scatter/@pre marker code is transformed such that (0,0) is the plot coordinate. However, this does not seem to be the case.

\documentclass{article}

\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}

\begin{tikzpicture}
  \begin{axis} [
        scatter,
        scatter/@pre marker code/.append code={
          \draw (0,0) circle [radius=.2cm];
        },
      ]
    \addplot+ {x^2 - 5};
  \end{axis}
\end{tikzpicture}

\end{document}

image

There's an additional offset. From playing around with the function a bit it seems like, modulo some rounding/imprecision, the offset is (xmin, ymin), where xmin (ymin) is the minimum of the data's x (y) coordinates.

schtandard commented 4 weeks ago

After playing around a bit more, it seems like error bars also feed into (xmin, ymin), so it's probably just the minimum of the data ranges (i.e. the lower left corner of the data area).