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/
200 stars 35 forks source link

Problem with ticks in logarithmic scale - math parse error #135

Open pgf-tikz-bot opened 8 years ago

pgf-tikz-bot commented 8 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/135/ Author: mo-gul Timestamp: 2016-09-26 19:08:53.378000

It seems that the math parser is confused when the ticks are given by a command. Is that a bug or "intended"? (This issue was first reported here: http://tex.stackexchange.com/questions/331229/pgfplots-problem-with-ticks-in-logarithmic-scale-math-parse-error

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\newcommand\xtickdef{0.005,0.0005}
\begin{tikzpicture}
  \begin{axis}[xmode=log,xtick={\xtickdef}]
    \addplot table {
      0.0001 10
      0.001 20
      0.01 15
    }; 
  \end{axis}
\end{tikzpicture}
\end{document}
pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/bugs/135/#5325 Author: symbol-1 Timestamp: 2017-07-21 18:12:05.389000

This is pgfplots.code.tex line 10048-10059: (#1 is x in this place)

        \edef\pgfplots@loc@TMPa{\csname pgfplots@#1tick\endcsname}%
        \ifx\pgfplots@loc@TMPa\pgfutil@empty
        \else
            \def\pgfplots@loc@TMPb{data}%
            \ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
                % #1tick=data is handled elsewhere...
            \else
                \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tick\endcsname
                \expandafter\pgfplots@filter@input@ticks@with@log\expandafter{\pgfplots@loc@TMPa}{#1}%
                \expandafter\edef\csname pgfplots@#1tick\endcsname{\pgfmathresult}%
            \fi
        \fi

One sees that at the first line \edef is used. But at the 8th line the definition is rewritten by a \let. Now \pgfplots@loc@TMPa is \xtickdef and the 9th line generates the error.

I know there are instances where \edef is dangerous so \let is used. But this time, since \edef is already used, there is no obvious reason to use \let at all.

Keep reading line 10060-10072, one sees that same thing happens among extraxticks and minorxtick. (Recall that \pgfkeysgetvalue is a \let.)