1

On page 186 of the PGFplots manual Revision 1.12 (2015/01/31) an example of the use of point meta is given:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[colorbar]
            %\addplot[mesh,point meta=y,thick] {x^2}; % WORKS!
            \addplot+[point meta=explicit] coordinates
            {%
                (0,0) [1.0e10]
                (1,2) [1.1e10]
                (2,3) [1.2e10]
                (3,4) [1.3e10]
            }; % DOES NOT WORK! WHY NOT?
        \end{axis}
    \end{tikzpicture}
\end{document}

But the coloring of the graph is just blue everywhere. What is wrong with the code?

1
  • Add the mesh option: \addplot+[mesh,point meta=explicit] coordinates – esdd Mar 17 '15 at 17:40
2

You have to add the mesh or surf option to the \addplot+ command.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[colorbar]
            %\addplot+[mesh,point meta=y,thick] {x^2}; % WORKS!
            \addplot+[mesh,point meta=explicit] coordinates
            {%
                (0,0) [1.0e10]
                (1,2) [1.1e10]
                (2,3) [1.2e10]
                (3,4) [1.3e10]
            };
        \end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.