[Tex/LaTex] Make plot smoother in pgfplots

3dpgfplots

I'm trying to plot a function using pgfplots:

\documentclass{scrartcl}

\usepackage{pgfplots}
\pgfplotsset{compat = 1.12}

\newcommand{\param}{2.0}

\begin{document}
        \begin{tikzpicture}
          \begin{axis}[view={40}{50}]
            \addplot3[surf, domain = 0:1, y domain = 0:1, unbounded coords=jump,
            samples = 50]
            {x^(-\param-1)*y^(-\param-1)*(x^(-\param)+y^(-\param)-1)^(-1/\param-2)+\param*x^(-\param-1)*y^(-\param-1)*(x^(-\param)+y^(-\param)-1)^(-1/\param-2)};
        \end{axis}
      \end{tikzpicture}
\end{document}

This results in:

Pgfplots output

Compared with (plotted in the OS X Grapher application)

OS X grapher output

the plot generated by pgfplots is a lot "rougher" near x=y=0. I have tried increasing the number of samples from the default to 50 but that hasn't really improved the plot much.

Best Answer

The default surface plot of pgfplots uses two triangles for each rectangular patch segment. Usually, the diagonal does not matter much -- but in this case, it really matters and the result is unsuitable.

Note that shader=interp appears to select the other diagonal (unintentionally, but it does). A simple solution would be to add shader=interp, unless you really need the grid lines.

\documentclass{standalone}

\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\pgfplotsset{compat = 1.12}

\newcommand{\param}{2.0}

\begin{document}
        \begin{tikzpicture}
          \begin{axis}[view={40}{50}]
            \addplot3[surf, domain = 0:1, y domain = 0:1, unbounded coords=jump,
                shader=interp,
                samples = 25]
            {x^(-\param-1)*y^(-\param-1)*(x^(-\param)+y^(-\param)-1)^(-1/\param-2)+\param*x^(-\param-1)*y^(-\param-1)*(x^(-\param)+y^(-\param)-1)^(-1/\param-2)};
        \end{axis}
      \end{tikzpicture}
\end{document}

enter image description here