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?

  • To those attempting to draw the object: so far everyone has it wrong. It is a half cylinder (since $y>0$), drawn from z=1 to z=5. – Benjamin McKay Feb 25 '14 at 8:24
  • Also the Radius dictates -2<=x<=2, 0<y<=2 – user46794 Feb 25 '14 at 16:09
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

  • Wrong Radius, also the set is a half-cyllinder closed off at the top and bottom, your parametrisation is wrong though so the LateX code might work. I'll try it out later. Thanks for the input! – user46794 Feb 25 '14 at 16:11
  • the pgfplots solution requires z buffer=sort – Christian Feuersänger May 10 '14 at 17:16
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. – user11232 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. :) – user11232 Feb 24 '14 at 23:55

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.