3

Since this seems doesn't work anymore, there's a way to make a sharp transition in a pgfplots colormap gradient color?

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

\pgfplotsset{
    colormap={blackwhite}{[5pt]
        rgb255(0pt)=(255, 200, 0);
        rgb255(500pt)=(255, 75, 0);
        rgb255(500pt)=(0, 100, 255);
        rgb255(1000pt)=(0, 255, 255)
    },
}

\begin{tikzpicture}
    \begin{axis}[colorbar]
\addplot [scatter, samples=50] {x};
\end{axis}
\end{tikzpicture}

\end{document}

TeXworks error message:

! Package pgfplots Error: Colormaps must have increasing positions. The provide d colormap has mesh width '0.0' at rgb255(500pt)=(0, 100, 255) (color no 101) . Please assign increasing positions.

6

As noted in a comment under the referenced answer it's wrong to specify the same point twice, this is now apparently detected in the updated tex package and produces an error in tex rather than leave it to (some) pdf viewers to detect. if I change the second 500pt to the next position, 505pt it runs without error. enter image description here

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

\pgfplotsset{
    colormap={blackwhite}{[5pt]
        rgb255(0pt)=(255, 200, 0);
        rgb255(500pt)=(255, 75, 0);
        rgb255(505pt)=(0, 100, 255);
        rgb255(1000pt)=(0, 255, 255)
    },
}

\begin{tikzpicture}
    \begin{axis}[colorbar]
\addplot [scatter, samples=50] {x};
\end{axis}
\end{tikzpicture}

\end{document}

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.