I exported a surface plot from MATLAB using matlab2tikz. For some reason, the pgfplot differs from the MATLAB plot in a way that information deeper in the image plane appear above. As images describe it better than words, compare below. The upper image is from MATLAB, the lower one is what pgfplots made out of it. By the way, the problem solves when I allow more space in x axis direction, unfortunately this is no option in my document.

This is how it should look (from MATLAB) This is the LateX-pgfplots output

I fixed an example, which is by intention not minimum but reduced (regarding the data in the table) but hopefully helps to solve the problem. I can upload or send it in case of need (after I found out how to do that).

Any suggestions welcome!

  • 1
    It's hard to tell without seeing your code, but you should try setting y buffer=sort.
    – Jake
    Dec 7, 2015 at 15:24
  • @Jake your hint was the way to the solution. The matlab2tikz code hat z buffer=sort by default. y buffer does not seem to exist. But deleting the z buffer=sort did the trick! Thanks!
    – MP Felder
    Dec 7, 2015 at 16:00

1 Answer 1


The solution to this perspective confusion is to experiment with the \addplot3[] option z buffer=sort, which was automatically added by matlab2tikz in my case. Deleting that argument did the trick for me.

You must log in to answer this question.

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