Explicação

Explicação

Então, depois dosolução brilhante de @Symbol1à minha última pergunta, tenho uma nova sobre o mesmo assunto. Com o código proposto, que altera o comportamento de \pgfplotsplothandlerquiver@vis@path, point metaparece não funcionar mais...

Isto tem efeitos sobre mapped colore\pgfplotspointmetatransformed

\documentclass[border=9,tikz]{standalone} 
\usepackage{pgfplots}\pgfplotsset{compat=newest}
\usetikzlibrary{arrows.meta}
\begin{document}

\makeatletter
\def\pgfplotsplothandlerquiver@vis@path#1{%
    % remember (x,y) in a robust way
    #1%
    \pgfmathsetmacro\pgfplots@quiver@x{\pgf@x}%
    \pgfmathsetmacro\pgfplots@quiver@y{\pgf@y}%
    % calculate (u,v) in relative coordinate
    \pgfplotsaxisvisphasetransformcoordinate\pgfplots@quiver@u\pgfplots@quiver@v\pgfplots@quiver@w%
    \pgfplotsqpointxy{\pgfplots@quiver@u}{\pgfplots@quiver@v}%
    \pgfmathsetmacro\pgfplots@quiver@u{\pgf@x-\pgfplots@quiver@x}%
    \pgfmathsetmacro\pgfplots@quiver@v{\pgf@y-\pgfplots@quiver@y}%
    % move to (x,y) and start drawing
    {%
        \pgftransformshift{\pgfpoint{\pgfplots@quiver@x}{\pgfplots@quiver@y}}%
        \pgfpathmoveto{\pgfpointorigin}%
        \pgfpathlineto{\pgfpoint\pgfplots@quiver@u\pgfplots@quiver@v}%
    }%
}%

  \begin{tikzpicture}
    \begin{axis}[axis equal]

      \addplot[
               point meta=x,
               quiver={u=x,v=y,
                 after arrow/.code={
                   \relax{% always protect the shift
                     \pgftransformshift{\pgfpoint{\pgfplots@quiver@x}{\pgfplots@quiver@y}}%
                     \node[below right]{\tiny\color{mapped color}\pgfplotspointmetatransformed};
                   }
                 }
               },
               ->,
               samples=10,domain=-1:1
              ] {x*x-1};


      \addplot[
               point meta=x,
               quiver={u=x,v=y,
                      every arrow/.append style={%
                        -{Latex[scale length={max(0.1,\pgfplotspointmetatransformed/1000)}]},mapped color
                      },
               },
               ->,
               samples=10,domain=-1:1
              ] {x*x};
   \end{axis}
  \end{tikzpicture}
\end{document}

Para a versão inalterada, o dimensionamento e a coloração funcionam; para a versão alterada, nenhuma das duas coisas funciona.

insira a descrição da imagem aqui

Para completar, o pgfplotscódigo original que é substituído (não consigo ver nada sobre meta-valores aqui?!?)

\def\pgfplotsplothandlerquiver@vis@path#1{%
    \pgfpathmoveto{#1}%
    \pgfplotsaxisvisphasetransformcoordinate\pgfplots@quiver@u\pgfplots@quiver@v\pgfplots@quiver@w
    \pgfpathlineto{%
        \pgfplotsifcurplotthreedim{%
            \pgfplotsqpointxyz\pgfplots@quiver@u\pgfplots@quiver@v\pgfplots@quiver@w
        }{%
            \pgfplotsqpointxy\pgfplots@quiver@u\pgfplots@quiver@v
        }%
    }%
}%

Responder1

O seguinte funciona para mim.

\documentclass[border=9,tikz]{standalone} 
\usepackage{pgfplots}\pgfplotsset{compat=newest}
\usetikzlibrary{arrows.meta}
\begin{document}

\makeatletter
\def\pgfplotsplothandlerquiver@vis@path#1{%
    % remember (x,y) in a robust way
    #1%
    \pgfmathsetmacro\pgfplots@quiver@x{\pgf@x}\global\let\pgfplots@quiver@x\pgfplots@quiver@x%
    \pgfmathsetmacro\pgfplots@quiver@y{\pgf@y}\global\let\pgfplots@quiver@y\pgfplots@quiver@y%
    % calculate (u,v) in relative coordinate
    \pgfplotsaxisvisphasetransformcoordinate\pgfplots@quiver@u\pgfplots@quiver@v\pgfplots@quiver@w%
    \pgfplotsqpointxy{\pgfplots@quiver@u}{\pgfplots@quiver@v}%
    \pgfmathsetmacro\pgfplots@quiver@u{\pgf@x-\pgfplots@quiver@x}%
    \pgfmathsetmacro\pgfplots@quiver@v{\pgf@y-\pgfplots@quiver@y}%
    % move to (x,y) and start drawing
    {%
        \pgftransformshift{\pgfpoint{\pgfplots@quiver@x}{\pgfplots@quiver@y}}%
        \pgfpathmoveto{\pgfpointorigin}%
        \pgfpathlineto{\pgfpoint\pgfplots@quiver@u\pgfplots@quiver@v}%
    }%
}%

    \begin{tikzpicture}
        \begin{axis}[axis equal]
            \addplot[
                point meta=x,
                quiver={
                    u=x,v=y,
                    every arrow/.append style={%
                        -{Latex[scale length={max(0.1,\pgfplotspointmetatransformed/1000)}]},mapped color
                    },
                    after arrow/.code={
                        \relax{% always protect the shift
                            \pgftransformshift{\pgfpoint{\pgfplots@quiver@x}{\pgfplots@quiver@y}}%
                            \node[below right]{\tiny\color{mapped color}\pgfplotspointmetatransformed};
                        }
                    }
                },
                ->,samples=10,domain=-1:1
            ]{x*x-1};
            \addplot[
                point meta=x,
                quiver={
                    u=x,v=y,
                    every arrow/.append style={%
                        -{Latex[scale length={max(0.1,\pgfplotspointmetatransformed/1000)}]},mapped color
                    },
                },
                ->,samples=10,domain=-1:1
            ]{x*x};
        \end{axis}
    \end{tikzpicture}
\end{document}

Explicação

A principal diferença deste código e da sua pergunta anterior é que

\pgfmathsetmacro\pgfplots@quiver@x{\pgf@x}
\pgfmathsetmacro\pgfplots@quiver@y{\pgf@y}

é feito em

\pgfmathsetmacro\pgfplots@quiver@x{\pgf@x}\global\let\pgfplots@quiver@x\pgfplots@quiver@x%
\pgfmathsetmacro\pgfplots@quiver@y{\pgf@y}\global\let\pgfplots@quiver@y\pgfplots@quiver@y%

o que sugere que o erro é introduzido por agrupamento extra. Mas por que existe um agrupamento extra? Bem, porque quando o pgfplots encontra

\draw[/pgfplots/quiver/every arrow]...

as opções do \drawestão, por convenção, afetando apenas isso \draw. Daí TikZ colocará isso \drawem um grupo. E como \pgfplotsplothandlerquiver@vis@pathé assim colocado num grupo, não se pode ver \pgfplots@quiver@xde fora (em particular em after arrow).


A propósito, o #1do \pgfplotsplothandlerquiver@vis@pathé, grosso modo,

\global\pgf@x=\pgf@x
\global\pgf@x=\pgf@y

E a análise acima mostra a necessidade disso.

informação relacionada