6

I am using MikTex and Texworks with pgfplots to try and plot 3 and 2-dimensional sets

Could some of you nice fellas help me out? I am trying to plot:

image

I can print out the page and draw per hand too, actually I'd like to know how to print a blank coordinate system with x,y,z labels and arrows at the axis in addition to plotting those things in LateX directly.

Must I convert the given form into the polar coordinate system or is there another, direct way?

user46794
  • 131

2 Answers2

7

One possibilty is to parametrize the surface:

  • x = 4 * cos(u), 0 < u < 2 pi
  • y = 4 * sin(u), 0 < u < 2 pi
  • z = v, 1 < u < 5

Example

\documentclass[tikz,border=3pt]{standalone}
\usepackage{amsmath,amssymb,pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}
        \addplot3[surf,samples=25,samples y=31,domain=1:5,y domain=0:2*pi] ({4*cos(deg(y))},{4*sin(deg(y))},{x});
        \addlegendentry{$A = \left\{ (x,y,z) \in \mathbb{R}^3 \middle| x^2 + y^2 \le 4, 0 < y, 1 \le z \le 5 \right\}$};
    \end{axis}
\end{tikzpicture}
\end{document}

Output

enter image description here


Using asymptote

import graph3;
import palette;
import solids;

size(12cm,IgnoreAspect);
currentprojection=orthographic(1,-2,1);

triple cylinder(real z) {
  return (4,0,z);
}

real color(triple v)
{
  return v.z;
}

revolution object=revolution(graph(cylinder,1,5,20,operator ..),axis=Z);
surface s = surface(object);
s.colors(palette(s.map(color),Wheel()));
draw(s,render(compression=Low,merge=true));

xaxis3("$x$",Bounds,InTicks);
yaxis3("$y$",Bounds,InTicks);
zaxis3("$z$",Bounds,InTicks);

enter image description here

Henri Menke
  • 109,596
7

run with xelatex

\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}
\begin{document}
\psset{unit=0.75}
\begin{pspicture}(-6,-4)(6,6)
\psset{viewpoint=20 120 40 rtp2xyz,Decran=15,lightsrc=-10 15 10}
\psSolid[object=grille,base=-5 6 -6 4,action=draw*,linecolor={[cmyk]{1,0,1,0.5}}](0,0,0)
\defFunction[algebraic]{A}(u,v){4*cos(u)}% x(u)
                               {4*sin(u)}% y(u)
                               {v}       % z(v)
\psSolid[object=surfaceparametree,linecolor={[cmyk]{1,0,1,0.5}},base=0 pi pi add 1 5,
  fillcolor=blue!50,incolor=green!20,function=A,linewidth=0.5\pslinewidth,ngrid=40 4]%
 \end{pspicture}

\end{document}

enter image description here

and the same for only y>0 and a different viewpoint:

\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}
\begin{document}
\psset{unit=0.75}
\begin{pspicture}(-6,-4)(6,6)
\psset{viewpoint=20 -40 20 rtp2xyz,Decran=15,lightsrc=viewpoint}
\psSolid[object=grille,base=-4 5 -6 4,action=draw*,linecolor={[cmyk]{1,0,1,0.5}}](0,0,0)
\defFunction[algebraic]{A}(u,v){4*cos(u)}% x(u)
                               {4*sin(u)}% y(u)
                               {v}       % z(v)
\psSolid[object=surfaceparametree,linecolor={[cmyk]{1,0,1,0.5}},base=0 pi 1 5,
  fillcolor=blue!50,incolor=green!20,function=A,linewidth=0.5\pslinewidth,ngrid=20 4]
\axesIIID(6,4,6-)
%\gridIIID[Zmin=0,Zmax=5](-4,5)(-4,4)
\end{pspicture}

\end{document}

enter image description here

and for a closed solid:

\documentclass[pstricks]{standalone}
\usepackage{pst-solides3d}
\begin{document}
\psset{unit=0.75}
\begin{pspicture}[solidmemory](-4,-3)(6,6)
\psset{viewpoint=20 -40 30 rtp2xyz,Decran=15,lightsrc=viewpoint}
\psSolid[object=grille,base=-5 4 -1 5,linecolor={[cmyk]{1,0,1,0.5}}](0,0,0)
\defFunction{F}(t){t cos 4 mul}{t sin 4 mul}{}%  A circle
\psSolid[object=prisme, h=4,fillcolor=blue!30,incolor=green!20,ngrid=8 9, 
   base=0 180 {F} CourbeR2+ ](0,0,1) 
\axesIIID(4,7,5)(5,8,6)
\end{pspicture}

\end{document}

enter image description here

  • 2
    surfaceparametree,grille, etc should be translated to English such that users do need to waste their time to remember new vocabularies from other languages. – kiss my armpit Feb 24 '14 at 23:16
  • 1
    vecteur, cylindre, cylindrecreux, conecreux, tronccone, troncconecreux, calottesphere, tore, anneau, prisme, grille, ruban, etc are difficult to remember. – kiss my armpit Feb 24 '14 at 23:21
  • 1
    @TheLastError That is why I am afraid of pstricks. I can't remember its terminology and command names as well :(. But it is very powerful. –  Feb 24 '14 at 23:49
  • @HarishKumar: One more thing that you need is the inconsistent syntax. :-) – kiss my armpit Feb 24 '14 at 23:52
  • @TheLastError I agree. The ultimate result is, I want to use pstricks, but don't even feel like starting :(. I am writing this as a humble request to Herbert to make syntax and command names user freindly. :) –  Feb 24 '14 at 23:55
  • Your result is painting one part of the set though, the set is a volume, therefore the has to be something closing off the top, the bottom and the side. – user46794 Feb 25 '14 at 16:10
  • @user46794: see my edit –  Feb 25 '14 at 16:51