5

I'd like to apply thickness to my plot, similarly to what's shown in the image on the right.

enter image description here

\documentclass[border=5mm]{standalone}   
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\usepgfplotslibrary{colorbrewer}

\begin{document}
\begin{tikzpicture}[yscale=1]
\begin{axis}[
domain=-180:180,
samples=50,
colormap/PiYG,
colorbar,
colorbar style={
    title=Color key,
    ylabel=Z-value,
    ytick={-1,-0.75,...,1},
    yticklabel style={
        text width=2.5em,
        align=right,
        /pgf/number format/.cd,
            fixed,
            fixed zerofill
        }
    }
]
\addplot3 [surf] { cos(x)*cos(y) / 5};
\end{axis}
\end{tikzpicture}
\end{document}
Alenanno
  • 37,338
sayros
  • 2,629

1 Answers1

5

This question is all about origami: how you can make a box out of a paper?

\documentclass[border=9]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}

\begin{document}

    \pgfmathdeclarefunction{X}{2}{%
        \pgfmathparse{
            #1<-180?
                -180                    % west side
                :
                #1                      % main surface
        }%
    }
    \pgfmathdeclarefunction{Y}{2}{%
        \pgfmathparse{
            #2<-180?
                -180                    % south side
                :
                #2                      % main surface
        }%
    }
    \pgfmathdeclarefunction{Z}{2}{%
        \def\zoffset{0}%
        \pgfmathsetmacro\x{
            #1<-180?
                -180                    % west side
                :
                #1                      % main surface
        }%
        \ifpgfmathfloatcomparison%
            \def\zoffset{.5}%
        \fi%
        \pgfmathsetmacro\y{
            #2<-180?
                -180                    % south side
                :
                #2                      % main surface
        }%
        \ifpgfmathfloatcomparison%
            \def\zoffset{.5}%
        \fi%
        \pgfmathparse{
            cos(\x)*cos(\y)-\zoffset
        }%
    }

    \begin{tikzpicture}
        \begin{axis}[
            domain=-186:180,
            samples=62,
            view={-30}{40}
            ]
            \addplot3 [surf]
                ({X(x,y)},{Y(x,y)},{Z(x,y)});
        \end{axis}
    \end{tikzpicture}
\end{document}

Symbol 1
  • 36,855