matlab2tikz / matlab2tikz

This program converts MATLAB®/Octave figures to TikZ/pgfplots figures for smooth integration into LaTeX.
http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz
BSD 2-Clause "Simplified" License
1.56k stars 318 forks source link

Mesh legend does not support zbuffer sort and ACID(58) fails #504

Closed egeerardyn closed 9 years ago

egeerardyn commented 9 years ago

When double-checking current feature branches, I noticed that ACID(58) in MATLAB R2014a produces output that cannot be compiled by a LaTeX compiler by our latest develop branch (i.e. 285dc83 )

In the error log, one of the symptoms is:

! Undefined control sequence.
<argument> ...ots@current@point@x ,\pgfplots@current@point@y 
                                                  ,\pgfplots@current@point@z 
l.257 \end{axis}

I haven't inspected this further, this issue report is just to make sure we do not forget this.

okomarov commented 9 years ago

The problem is caused by the z buffer = sort introduced in 027dfd22ac2760cafa215bac794b1e623646bcd9

This MWE will error (and after removing the z buffer, it will compile but with wrong coloring):

\documentclass[tikz]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}

\begin{axis}[view={-37.5}{30},z buffer=sort]

\addplot3[surf, draw=black, mesh/rows=2]
table[row sep=crcr,header=false,point meta=\thisrowno{2}] {%
%
1   1   2\\
1   2   1.715921\\
1   3   1\\
1   4   1.793604\\
1   5   2.236068\\
1   6   2\\
1   7   1\\
1   8   2.557537\\
1   9   4.236068\\
1   10  5.520147\\
};
\addlegendentry{legendary};

\end{axis}
\end{tikzpicture}%
\end{document}
okomarov commented 9 years ago

I read in the pgfplots manual that z buffer = sort might fail. I wonder if the error produced by the above MWE is the failure that the manual talks about (maybe @cfeuersaenger can confirm).

cfeuersaenger commented 9 years ago

This is a bug in pgfplots.

It happens because the small mesh drawn into the legend does not seem to support 'z buffer=sort'.

A workaround is to add

legend image post style={/pgfplots/z buffer=default}

I will have fixed this for pgfplots 1.12 (which will become the next stable within the next weeks).

Thanks for the report.

Kind regards

Christian

Am 04.01.2015 15:35, schrieb Oleg Komarov:

I read in the pgfplots manual that |z buffer = sort| might fail. I wonder if the error produced by the above MWE is the failure that the manual talks about (maybe @cfeuersaenger https://github.com/cfeuersaenger can confirm).

— Reply to this email directly or view it on GitHub https://github.com/matlab2tikz/matlab2tikz/issues/504#issuecomment-68634808.

egeerardyn commented 9 years ago

@cfeuersaenger Thanks for confirming this.

This means we can either add that work-around to our legend generation code and/or when 1.12 is released have that version marked as required from our part when we enforce z-sorting. The latter should be our long-term solution, anyhow, but the other could help in the meanwhile for our developers.

okomarov commented 9 years ago

I reckon we should go with your suggestion @egeerardyn. First the workaround then use 1.12.

PeterPablo commented 9 years ago

Let's add legend image post style={/pgfplots/z buffer=default}, as a workaround for now. It probably will take some time after the release of pgfplots 1.12 until it is widely adopted.

PeterPablo commented 9 years ago

@egeerardyn, is this something for the version 1.0 release milestone or do we want to stick to requiring pgfplots 1.12, which is by now released?

egeerardyn commented 9 years ago

@PeterPablo We might as well recommend pgfplots 1.12 for z-sorting. No need for a work-around on our side any more, I'd say.

PeterPablo commented 9 years ago

Fine by me. Searching the internet for the error message directly leads here. Let me post a command for Linux that updates the current user's pgfplots to the newest available release: cd ~/texmf; wget http://mirrors.ctan.org/install/graphics/pgf/contrib/pgfplots.tds.zip; unzip pgfplots.tds.zip; texhash ~/texmf; rm pgfplots.tds.zip

PeterPablo commented 9 years ago

I am closing here, since a workaround exists for pgfplots <= 1.11 and the problem is fixed by pgfplots 1.12 which is by now publicly available on CTAN.org.

egeerardyn commented 9 years ago

We should add this into the code as well, so we shouldn't close yet.