This question is a result of this one. I would like to make a surface plot using tikz/pgfplots using explicit colour and including legends. Is this possible? I have gone through the entire manual for pgfplots without seeing any examples of this combined. If I try to do it I get the error

! Package pgfplots Error: Sorry, color input!=colormap requires 'point meta=sym

but, I have set point meta to explicit symbolic and it works if I leave out the legend.

Here is the specific tikz file, right below the data is the legend entry which is commented out for it to work.

I would very much appreciate any feedback on this, it would be beyond cool to get it to work, but on the other hand it would be nice to know if it is not possible so I can let it go :)

1 Answer 1


This is configuration bug in pgfplots: the default legend for mesh/surface plots relies on a colormap -- but it does not set mesh/color input=colormap. Consequently, it inherits the choice of the plot and is confused.

A simple work-around is to add

legend image post style={/pgfplots/mesh/color input=colormap},

to your option list (or to configure this in your main tex file using \pgfplotsset{...}).

You can also add a different colormap to that list or choose an entirely different legend (like area legend).

I fixed the configuration issue for the next release of pgfplots.

  • Thank you very much for your response! I am by no means an expert so you may excuse stupidity. Doing this allows me to get legends, which is of course nice but it does not use colours that fit the ones from external (i.e. the explicit colours in the data). Is this also possible to get? :)
    – htd
    Oct 11, 2014 at 13:05
  • I have changed to just using your colormaps and it looks beautiful :)
    – htd
    Oct 11, 2014 at 13:52
  • I am glad that my answer addresses your needs. Regarding the actual colors: pgfplots cannot use explicit colors of the surface for the legend. Doing so would be a feature request (a very special one as well imho). Oct 11, 2014 at 14:15
  • Yea! I realised that, it was indeed not very important to be able to do.
    – htd
    Oct 11, 2014 at 14:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .