TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I load an external custom colormap with


I have a range of complex surface plots created with matlab2tikz which use this colormap and compile successfully. One does not. It fails with this error:

! Package pgfplots Error: No such element: \pgfplotsarrayselect257\of{pgfpl@cm@

I tried the fix given here but it does not work.

You can look at the colormap here.

The working tikzpicture is here.

The non-working tikzpicture is here.

I am wondering if it has anything to do with the plot type; the one that fails is a nearest neighbour interpolation with some very steep surfaces, the other is a cubic interpolation.

EDIT: Yes, this is a clue to the cause -- the other nearest neighbour surface plot in my collection, produced with MATLAB's TriScatteredInterp, produces exactly the same error when using this colormap.

share|improve this question
up vote 1 down vote accepted

This is due to a bug in pgfplots v1.8 (or earlier). It has already been fixed and will be part of the next stable 1.9.

Pre-release downloads can be retrieved from http://pgfplots.sourceforge.net/

share|improve this answer
Thanks for the tip. I'm still puzzled why it happens with the one plot, but not the other, though. What's the nature of the bug? Can you elaborate? – Stephen Bosch Sep 29 '13 at 17:04
It is related to rounding/interpolation of color values near the upper end of the color map: there was a defect in a check which manifested itsself only under strange circumstances. – Christian Feuersänger Sep 29 '13 at 17:53
The prerelease version of pgfplots does indeed correct the problem. Best of all, my other graphics still compile, too ;) – Stephen Bosch Sep 29 '13 at 19:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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