I've got some issues using the matlab2tikz script by Nico Schlömer. In Matlab I created a 3d plot including a bunch of patches. Some scalar values are highlighted using the jet colormap (see the attached *.png file).

Matlab figure

I then translated this figure into a tikzpicture by invoking matlab2tikz('Test6.tex'). Matlab printed the information

> Found colormap/jet to be a pretty good match for your color map (||diff||=0.0280337).

Compiling the rather huge tikz file by

\usetikzlibrary{external} \tikzset{external/system call={lualatex
    \tikzexternalcheckshellescape -halt-on-error
    -interaction=batchmode -jobname "\image" "\texsource"}}


\caption{\label{fig:1}Our figure}

using pdflatex produces this results (screenshot of corresponding pdf)

[Resulting output[2]

Both, the colormap and the colorbar are obviously completely different to the original plot. Can anyone help me fixing this issue?

  • Judging by your description and the answer below, this sounds very much like matlab2tikz doing the wrong thing, and that is something that should be reported at github.com/matlab2tikz/matlab2tikz/issues if you haven't already. Bug reports like that are off-topic here. It would also be great if you could give some feedback to Jonas, whether his answer helped or not. (Leave a comment and/or upvote/accept.) Commented Sep 5, 2016 at 13:33

1 Answer 1


I experienced the same issue. I think there is an error in the generation of the colormap in the matlab2tikz.m file. You will have to change some things in your Test6.tex file:

In your tex file there should be the following lines:

point meta min=...,
point meta max=...,

With on the dots your values. This limits the colours of your colormap. These two lines needs to be removed. After doing this already a plot should be generated with the right color values but the colorbar definition will still wrong in order to fix this, the next code block

colormap={mymap}{[1pt] ...}

needs to be placed after

colormap={patchmap}{[1pt] ...}

This will fix the colorbar. But still the tickvalues of the colorbar will be off. This can be fixed manually by using:

colorbar style={        

If it is not completely clear I can make the changes in your file.

You must log in to answer this question.

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