4

How can I fill with the region under the plot (x^2+y^2)/4 like in the following picture?

fill region under (x^2+y^2)/4

\documentclass{article}

\usepackage{pstricks}
\usepackage{pst-solides3d}
\definecolor{darkred}{RGB}{139,000,000}
\pagestyle{empty}

\begin{document}
\psset{viewpoint=20 40 30 rtp2xyz,Decran=25}
\psset{lightsrc=viewpoint,lightintensity=4}
\psset{unit=0.3}

\centering
\begin{pspicture}(-4,-4)(4,4)
\psSurface[ngrid=.25 .25,
  fillcolor=darkred,incolor=blue!40!white,
  axesboxed,
  Zmin=0,Zmax=8,
  action=draw**,
  linewidth=0.2pt](-4,-4)(4,4){x dup mul y dup mul add 4 div }
\end{pspicture}
\end{document}
5

That is not really easy. You have to define new objects, the stripes (polygons) under the curve. The four edges and the face (plane):

\documentclass{article}
\usepackage{pst-solides3d}
\definecolor{darkred}{RGB}{180,000,000}

\begin{document}
\begin{center}
\psset{viewpoint=40 30 30 rtp2xyz,Decran=20,lightsrc=viewpoint}

\begin{pspicture}(-4,-3)(4,6)
  \psSurface[ngrid=16 16,hue=0 1,fillcolor=yellow!50,
     axesboxed,algebraic,Zmin=0,Zmax=8,
     action=draw**,linewidth=0.2pt](-4,-4)(4,4){ (x^2+y^2)/4 }
\pstVerb{
  /fct {dup mul 16 add 4 div} def
  /Sommets1 { %  y=4
    4 -0.5 -3.5 {/xi exch def
    xi 4 0 xi 0.5 sub 4 0 xi 0.5 sub dup 4 exch fct
    xi dup 4 exch fct } for } def
  /Faces1 {
    0 4 [Sommets2] length 3 idiv 4 sub { /iF exch def
    [ iF iF 1 add iF 2 add iF 3 add ] } for } def
  /Sommets2 { % x=4
    -4 0.5 3.5 {/yi exch def
       4 yi 0 4 yi 0.5 add 0 4 yi 0.5 add dup fct
       4 yi dup fct } for } def
  /Faces2 {
    0 4 [Sommets2] length 3 idiv 4 sub { /iF exch def
    [ iF iF 1 add iF 2 add iF 3 add ] } for } def
}%
\psSolid[object=new,sommets=Sommets1,faces={Faces1},
    fillcolor=darkred,linewidth=0.2pt]
\psSolid[object=new,sommets=Sommets2,faces={Faces2},
    fillcolor=darkred,linewidth=0.2pt]
\end{pspicture}
\end{center}
\end{document}

enter image description here

  • Dear Herbert. Thanks for your answer. I'll try to understand your object creation. – sandro May 22 '14 at 9:20
3

It is sufficient to fill the visible space, i.e. the area below the border curves. On TeXwelt.de I recently showed how to do it answering: Wie fülle ich das Volumen unterhalb eines Plots im Raum?

  • Get the edge curves by fixing an x or y value
  • Plot the edge curves and give the path a name
  • Fill between named paths and the bottom line
  • Optionally shade to improve the 3d impression
  • Use layers if order of drawing would require it

enter image description here

Done with pfgplots, to show another approach:

\documentclass[border=15pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps,fillbetween}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
  \pgfdeclarelayer{pre main}
  \pgfsetlayers{pre main,main}
  \begin{axis}[
      hide axis,
      domain = -4:4,
      zmax   = 12,
      colormap/bone
    ]
    \begin{pgfonlayer}{pre main}
      \addplot3 [surf] {(x^2+y^2)/4};
    \end{pgfonlayer}
    \addplot3 [name path = xline, draw = none] (x,-4,0);
    \addplot3 [name path = yline, draw = none] (4,y,0);
    \addplot3 [name path = xcurve, y domain = 0:0, draw = none]
      (x, -4, {(x^2+16)/4});
    \addplot3 [name path = ycurve, y domain = 0:0, draw = none]
      (4, x, {(16+x^2)/4});
    \addplot [left color = black, right color = black!50, draw = none]
      fill between[of = xcurve and xline];
    \addplot [left color = black!50, right color = black, draw = none]
      fill between[of = yline and ycurve, reverse = true];
  \end{axis}
\end{tikzpicture}
\end{document}

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.