[Tex/LaTex] pgfplots how to smoothen up a surface plot with coordinates

pgfplotstikz-pgf

I have some coordinates not from some particular function…

\begin{document}
    \begin{figure}
        \begin{tikzpicture} 
            \begin{axis} [width=16cm,height=19cm,samples=100]
                \addplot3[surf]  coordinates {  
                (1,1,70)(2,1,48)(3,1,41)(4,1,70)( 5,1,68)(6,1,82)(7,1,38)(8,1,47)(9,1,35)(10,1,66)(11,1,53)(12,1,78)
                (1,2,91)(2,2,43)(3,2,68)(4,2,90)( 5,2,66)(6,2,55)(7,2,66)(8,2,46)(9,2,25)(10,2,38)(11,2,50)(12,2,58)
                (1,3,60)(2,3,68)(3,3,39)(4,3,65)( 5,3,59)(6,3,69)(7,3,72)(8,3,62)(9,3,94)(10,3,36)(11,3,33)(12,3,39)
                (1,4,48)(2,4,80)(3,4,68)(4,4,66)( 5,4,59)(6,4,63)(7,4,93)(8,4,63)(9,4,30)(10,4,52)(11,4,60)(12,4,14)};
            \end{axis}
        \end{tikzpicture}
    \end{figure} 
\end{document}

the result is this…

enter image description here

When I put the option smooth, like that…

\begin{document}
    \begin{figure}
        \begin{tikzpicture} 
            \begin{axis} [width=16cm,height=19cm,samples=100]
                \addplot3[smooth]  coordinates {  
                (1,1,70)(2,1,48)(3,1,41)(4,1,70)( 5,1,68)(6,1,82)(7,1,38)(8,1,47)(9,1,35)(10,1,66)(11,1,53)(12,1,78)
                (1,2,91)(2,2,43)(3,2,68)(4,2,90)( 5,2,66)(6,2,55)(7,2,66)(8,2,46)(9,2,25)(10,2,38)(11,2,50)(12,2,58)
                (1,3,60)(2,3,68)(3,3,39)(4,3,65)( 5,3,59)(6,3,69)(7,3,72)(8,3,62)(9,3,94)(10,3,36)(11,3,33)(12,3,39)
                (1,4,48)(2,4,80)(3,4,68)(4,4,66)( 5,4,59)(6,4,63)(7,4,93)(8,4,63)(9,4,30)(10,4,52)(11,4,60)(12,4,14)};
            \end{axis}
        \end{tikzpicture}
    \end{figure} 
\end{document}

I get the next image…

enter image description here

What I want is to have the continuous surface of the first image but smoothened like the curves in the second, not only along the x axis but also in depth… How can I achieve that???

Best Answer

You can adapt one of the solutions described in How to plot a surface from a set of data? to use the gnuplot backend in PGFPlots to generate a smooth surface:

\documentclass[border= 5mm]{standalone}
\usepackage{pgfplots, filecontents}

\begin{filecontents*}{data.txt}
1   1   70
2   1   48
3   1   41  
4   1   70
 5  1   68
6   1   82
7   1   38
8   1   47
9   1   35
10  1   66
11  1   53
12  1   78
1   2   91
2   2   43
3   2   68
4   2   90
 5  2   66
6   2   55
7   2   66
8   2   46
9   2   25
10  2   38
11  2   50
12  2   58
1   3   60
2   3   68
3   3   39
4   3   65
 5  3   59
6   3   69
7   3   72
8   3   62
9   3   94
10  3   36
11  3   33
12  3   39
1   4   48
2   4   80
3   4   68
4   4   66
 5  4   59
6   4   63
7   4   93
8   4   63
9   4   30
10  4   52
11  4   60
12  4   14
\end{filecontents*}

\begin{document}
    \begin{tikzpicture}
    \begin{axis}
    \addplot3 [surf] gnuplot [raw gnuplot] {
        set dgrid3d 50,50 spline;
        splot 'data.txt';       
    };
    \end{axis}
    \end{tikzpicture}
\end{document}
Related Question