10

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???

  • 3
  • 3
    To the person who downvoted this: Please make sure that you give the person who's asking a question a chance to improve their post, by leaving a comment explaining why you downvoted and how you think the question can be improved. Please also don't forget to come back and revert the down vote once the question has been improved. Finally, please note that on this site, down votes are typically reserved for exceptionally bad questions (i.e. spam). – Jake Nov 01 '13 at 20:03

2 Answers2

9

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}
Jake
  • 232,450
  • Thanks Jake! Thats wonderful! But when I use your code in my Latex I get the next message ...What do I do wrong? http://imageshack.us/photo/my-images/23/da7x.png/ – Ariscampis Nov 01 '13 at 20:09
  • @Ariscampis: Do you have gnuplot installed on your system? And are you running pdflatex with the shell-escape option? – Jake Nov 01 '13 at 20:26
  • I just checked and I use the shell-escape option... I think I must install gnuplot but I do not know how... – Ariscampis Nov 01 '13 at 20:49
8

Automatic smoothening of surfaces is unsupported by pgfplots (i.e. you could file feature requests).

Depending on how you obtain your data files, you may be able to increase the smoothness either by increasing the number of samples or by using higher order patch types which are offered by pgfplots's patchplots library (compare Creating Bezier surfaces using procedural graphics).

If your input is actually a math expression, you may be able to rely on the feature called patch type sampling which is also illustrated in the link mentioned above.

Everything which is beyond these work-arounds would need to be a feature request for pgfplots.