1

I'm trying to fill the region under the surface z = x^2 + y^2, over the rectangle 0<=x<=1, 0<=y<=1. How may I do so? Also, how do I orient the 3-d plot to as to have the x-axis coming towards me, the y-axis going to the right, and the z-axis going straight up. Here is what I have:

\documentclass[10pt]{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[xlabel=$x$,ylabel=$y$,zlabel=$z$]
        \addplot3
            [surf,faceted color=blue,
             samples=20,
             domain=-2:2,y domain=-2:2]
            {x^2 + y^2};
    \end{axis}
\end{tikzpicture}
\end{document}

bumped to the homepage by Community 11 hours ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

1

This sets the view which you seem to be asking for and fills the area as indicated (in this view) but is not really spectacular IMHO.

\documentclass[10pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[declare function={f(\x,\y)=\x*\x+\y*\y;}]
    \begin{axis}[xlabel=$x$,ylabel=$y$,zlabel=$z$,view={00}{00}]
        \addplot3
            [surf,faceted color=blue,
             samples=21,
             domain=-2:2,y domain=-2:2]
            {f(x,y)};
    \path[fill=blue]    (1,1,0) -- plot[samples=5,domain=1:0,variable=\x]
    (\x,1,{f(\x,1)}) --(0,1,0)--cycle;
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.