我想将以下集合可视化为的子集[0,\infty)^3
:
最有效的方法是什么?我正在考虑TikZ
或psTricks
。
答案1
我认为pgfplots
可以在这里使用,但你需要采取临时方法。
如果我正确理解了这个问题,那么将集合限制为[0,m]^3
(其中m
是某个非负值)对应于三个三角形凸包的并集:
(0,0,0)
,,(0,m,m)
(m,m,m)
(0,0,0)
,,(m,0,m)
(m,m,m)
(0,0,0)
,,(m,m,0)
(m,m,m)
\addplot3
我的方法是使用patch
和键分别绘制这三个三角形patch type=triangle
。为了获得漂亮的颜色,我更改了colormap
每个图的;可能有更好的方法...
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usepgfplotslibrary{colormaps}
\begin{document}
\[
\{(x,y,z)\in\mathbb{R}_+^3 :
(x=y, z\leq x) \vee (y=z, x\leq y) \vee (x=z, y\leq z)\}
\]
\centering
\begin{tikzpicture}
\def\xmax{1}
\begin{axis}[%
xtick={0,\xmax},
ytick={0,\xmax},
ztick={0,\xmax},
xlabel=x,
ylabel=y,
zlabel=z,
view={125}{45},
]
\addplot3[colormap/cold,opacity=.9,patch,patch type=triangle]
coordinates {
(0,0,0) (\xmax,\xmax,0) (\xmax,\xmax,\xmax)
};
\addplot3[colormap/bone,,opacity=.9,patch,patch type=triangle,]
coordinates {
(0,0,0) (\xmax,0,\xmax) (\xmax,\xmax,\xmax)
};
\addplot3[colormap/earth,opacity=.9,patch,patch type=triangle]
coordinates {
(0,0,0) (0,\xmax,\xmax) (\xmax,\xmax,\xmax)
};
\node[coordinate,pin=above:{(\xmax,\xmax,\xmax)}]
at (axis cs:1,1,1) {};
\end{axis}
\end{tikzpicture}
\end{document}
编辑:TikZ 中更优雅的替代方案:
\documentclass{article}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\begin{document}
\pgfmathsetmacro\xmax{1}
\[
\{
(x,y,z)\in\mathbb{R}_+^3 :
(y=z, x \leq y) \vee
(x=y, z \leq x) \vee
(z=x, y \leq z)
\}
\]
\centering
\tdplotsetmaincoords{45}{125}
\begin{tikzpicture}[scale=5,tdplot_main_coords]
\tikzset{
axis/.style={->,black},
framework/.style={dashed,black},
triang/.style={opacity=.8,},
}
\coordinate (O) at (0,0,0);
\tdplotsetcoord{P}{\xmax*sqrt(3)}{54.7356}{45} % arcsin(sqrt(2/3)) = 54.7356
\pgfmathsetmacro\endcoord{1.2*\xmax}
% draw the origin and axes
\draw (O) node[anchor=south]{$O$};
\draw[axis] (0,0,0) -- ({\endcoord},0,0) node[anchor=east]{$x$};
\draw[axis] (0,0,0) -- (0,{\endcoord},0) node[anchor=west]{$y$};
\draw[axis] (0,0,0) -- (0,0,{\endcoord}) node[anchor=south]{$z$};
% 1. Draw \{(x,y,z) \in [0,\xmax]^3 : (y=z, x \leq y) \}
\filldraw[
draw=red,%
fill=red!20,%
] (O)
-- (0,\xmax,\xmax)
-- (\xmax,\xmax,\xmax)
-- cycle;
% 2. Draw \{(x,y,z) \in [0,\xmax]^3 : (x=y, z \leq x) \}
\filldraw[
triang,%
draw=blue,%
fill=blue!20,%
] (O)
-- (\xmax,\xmax,0)
-- (\xmax,\xmax,\xmax)
-- cycle;
% 3. Draw \{(x,y,z) \in [0,\xmax]^3 : (z=x, y \leq z) \}
\filldraw[
triang,%
draw=green,%
fill=green!20,%
] (O)
-- (\xmax,0,\xmax)
-- (\xmax,\xmax,\xmax)
-- cycle;
% draw point M, its coordinates and dashed lines
\draw[framework] (P) -- (Pyz);
\draw[framework] (P) -- (Pxz);
\draw[framework] (P) -- (Pxy);
\draw[framework] (Px) -- (Pxy) -- (Py) -- (Pyz) -- (Pz) -- (Pxz) -- cycle;
\end{tikzpicture}
\end{document}