PGFPlots 3D Surface Plot – How to Use Data with Free Format

3dexternal filesgnuplotoctavepgfplots

I want to plot 3D data from a file (data file) using pgfplots. The data represents an ellipsoid. I want to draw the outer shell like in the following picture, just without the background and in grayscale:

ellipsoid

I tried several approaches following the threads here and here but I had no luck. Eitherway I don't get the outer shell quadrilaterals of the ellipsoid, or gnuplot is running at 100% CPU load for several minutes without any result.

Is it possible to do this with pgfplots and gnuplot or GNU Octave? How can it be done? Is the TeX memory sufficient?

My MWE:

\documentclass{scrreprt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{calc}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{figure}[htb]
\centering
\begin{tikzpicture}
\begin{axis}
\addplot3 [surf] gnuplot [raw gnuplot] {set dgrid3d 1152,1152 spline;splot 'criterion.txt';};
\end{axis}
\end{tikzpicture}
\end{figure}

\end{document}

Best Answer

Your data seems to be arranged in set of rectangular patches. So the key patch type=rectangle. Use opacity options to avoid (for the most part) the superposition problem (with axis) produced by current limitations of pgfplots. (For absolute control over the 3D object and lighs use Asymptote instead, in any case pgfplots will get you 99% there and it will be an improvement over gnuplot).

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{tikzpicture}
\begin{axis}[colormap/greenyellow, view = {150}{20}, axis equal, axis line style={opacity=0.5}, axis lines=center, xlabel=\small{$\sigma_\parallel$}, ticks=none, ylabel=\small{$\sigma_\perp$}, zlabel=\small{T}, xtick={}]
\addplot3+[patch, patch type=rectangle, mark=none, opacity=0.5, faceted color=black] file {
criterion.txt
}; 
\end{axis}
\end{tikzpicture}
\end{document}

This generates this plot:

crito

For reference criterion.txt data file looks like this:

-1229.428   -137.007    0.0
-1214.681   -163.451    0.0
-1215.0 -159.764    10.003
-1229.428   -137.007    0.0
-1214.681   -163.451    0.0
-1175.463   -187.298    0.0
-1176.097   -179.989    19.834
-1215.0 -159.764    10.003
-1175.463   -187.298    0.0
-1112.445   -208.142    0.0
...

(total lines: 1152)

Related Question