Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have done a lot of plotting in 2D using pgfplots but I am new to the 3D portion. I am attempting to illustrate a solid of revolution. For example, I have the area under the curve y = x^2 + 1 on the domain [0,5] (along with the curve rotated about both the x- and y- axes) illustrated with the following:

\documentclass[24pt, letter]{report}
\usepackage[fleqn]{mathtools}
\usepackage{amsthm, amssymb}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\pagenumbering{gobble}

\begin{document}
  % Curve + Area Underneath
  \begin{tikzpicture}
    \begin{axis}[title={$y=x^2+1$},
                 xticklabels={,$a$, , , , ,$b$} ,
                 yticklabels=\empty,
                 x=1.0cm,
                 y=0.2cm,
                 xmin=0, xmax=5.4,
                 ymin=0, ymax=26.9,
                 axis x line=bottom,
                 axis y line=left 
                ]
      \addplot[smooth,thick,domain=0:5, fill=blue!50]{1+x^2}\closedcycle;
      \node at (axis cs:3.75,4) [anchor=south]{$A$};
    \end{axis} 
  \end{tikzpicture}

  % Curve Rotated about y-axis
  \begin{tikzpicture}
    \begin{axis}[view={45}{45}]
      \addplot3[surf,shader=interp,samples=50,
                domain=0:5,y domain=0:2*pi,z buffer=sort]
        ({x*cos(deg(y))}, {x*sin(deg(y))}, {x^2+1});
    \end{axis}
  \end{tikzpicture}

  % Curve Rotated about x-axis
  \begin{tikzpicture}
    \begin{axis}[view={45}{45}]
      \addplot3[surf,shader=interp,samples=50,
                domain=0:5,y domain=0:2*pi,z buffer=sort]
        (x, {(x^2+1)*cos(deg(y))}, {(x^2+1)*sin(deg(y))});
    \end{axis}
  \end{tikzpicture}
\end{document} 

Is it possible to further the illustration by not only drawing the curve, but also the area under it? For example, when rotating about the y-axis, I'd like it to look not like a bowl, but like a cube with a bowl hollowed out of the top. Eventually I'd even like to be able to illustrate this with the area bounded by two curves, such as the area bounded by y=x^2+1, x=4, y=0, y=37.

Additionally, how would I draw the rotation about an arbitrary axis, such as the line y = -1 or x = 6?

share|improve this question
    
have a look at Can we make a love heart with LaTeX? and Surface of Revolution –  cmhughes Apr 19 at 23:37
    
Welcome to the site! Please let us know if the links I provided resolve the issue-they look like a duplicate (especially the second link) to me, but if your's is a follow-up question, that's ok too –  cmhughes Apr 19 at 23:39
    
Thanks @cmhughes! The second link definitely helped; however, I have updated my question to ask more specifically what I am looking to illustrate, which I believe is mostly a follow-up on the question answered in the second link. –  InsanesTheName Apr 20 at 2:18
    

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.