[Tex/LaTex] Draw a surface on a ternary diagram with pgfplots

pgfplotstikz-3dplottikz-pgf

I'd like to draw a surface on a ternary diagram.

Until now, I can plot density maps on a ternary diagram (cf. density map).
But I would like to replace the density map by a surface, like on figs a and b.

Is it possible to do it with tikzpgfplotsternaryaxistikz-3dplot ?

Best Answer

Regarding the two-dimensional ternary axes in your screen shot: yes, using its patch plots:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12} 
\usepgfplotslibrary{ternary}

\begin{document}
\begin{tikzpicture}
\begin{ternaryaxis}[
    axis on top,
    xlabel=x,ylabel=y,zlabel=z,
    colorbar]
\addplot3[
    patch,
    shader=interp,
    point meta=\thisrow{C}
] table{
     X Y Z C
     0 0 1  100
     1 0 0  0
     0.5 0.5 0  0

     0.5 0.5 0  0
     0 1 0  20
     0 0 1 100
};
\end{ternaryaxis}
\end{tikzpicture}
\end{document}

enter image description here

The plot handler expects a series of patches, per default using patch type=triangle. In my case, I provided two triangles, and provided the color data in column C of the input table.

All other plot handlers should work as well, even surf which expects a matrix of input values.

Regarding the three-d visualization: there is no builtin support for such axes.