我正在使用 MikTex 和 Texworks 与 pgfplots 尝试绘制三维和二维集合
你们这些好心人能帮我一下吗?我正在尝试策划:
我也可以打印出该页面并绘制每只手,实际上,除了直接在 LateX 中绘制这些内容之外,我还想知道如何打印带有 x、y、z 标签和轴上箭头的空白坐标系。
我必须将给定的形式转换为极坐标系吗?或者还有其他直接的方法吗?
答案1
一种可能性是对表面进行参数化:
x = 4 * cos(u)
,0 < u < 2 pi
y = 4 * sin(u)
,0 < u < 2 pi
z = v
,1 < u < 5
例子
\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}
输出
使用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);
答案2
运行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}
仅对于 y>0 和不同的视点,情况也是如此:
\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}
对于封闭固体:
\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}