Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I made a plot in MATLAB of a deformed and an undeformed model. I converted the figure to TikZ using matlab2tikz and added it to my .tex file. I then noticed that the two configurations, which are intersecting, are not displayed correctly. To illustrate what I mean, I've stripped down the TikZ code to make to rectangles cross in a 3D space:

\begin{tikzpicture}
\begin{axis}[%
    width=5cm,height=5cm,
    view={-37.5}{45},
    scale only axis,
    xmin=-3, xmax=23,
    ymin=0, ymax=20,
    zmin=-5, zmax=5,
    hide axis]
    \addplot3 [fill=white!80!red,opacity=0.5,draw=black] table[row sep=crcr]{
    20 0 0\\
    20 20 0\\
    0 20 0\\
    0 0 0\\
    };

    \addplot3 [fill=white!80!blue,opacity=0.8,draw=black] table[row sep=crcr]{
    15 5 -4\\
    15 15 0\\
    5 15 4\\
    5 5 0\\
    };
\end{axis}
\end{tikzpicture}

The result looks like this:

Two crossing planes

As can be seen one plane lies entirely on top of the other, while in fact they intersect (i.e. about half of the blue plane lies 'underneath' the red plane). With my minimum TikZ knowledge I was hoping someone here could help me fix this problem, such that the planes indeed intersect.

share|improve this question
    
As a workaround may be see 3) Fully Matlab section to export figure in a reasonable good quality, you may need to add appropriate packages in mlf2pdf.m. –  texenthusiast Apr 17 '13 at 17:12
add comment

1 Answer 1

up vote 4 down vote accepted

Unfortunately, this doesn't seem possible in the current version of pgfplots. From the manual (Section 4.5.1):

pgfplots supports z buffering techniques up to a certain extent. It works pretty well for single scatter plots (z buffer=sort), mesh or surface plots (z buffer=auto) or parametric mesh and surface plots (z buffer=sort). However, it can’t combine different \addplot commands, those will be drawn in the order of appearance. You may encounter the limitations sometimes. Maybe it will be improved in future versions.

share|improve this answer
1  
May be Asymptote for it has better 3D support‌​. –  texenthusiast Apr 18 '13 at 5:04
    
Thanks for the explanation. Seems like TikZ isn't the way to go for these kind of figures, too bad! –  George Urvey Apr 21 '13 at 9:42
add comment

Your Answer

 
discard

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.