# Draw an implicitly defined surface in 3D

I want to visualise the following set as a subset of [0,\infty)^3:

What's the most efficient way to do this? I am thinking of either TikZ or psTricks.

• @Jubobs How did you insert the TeX output? I wanted to do it like this but didn't know how. Aug 1, 2013 at 11:32
• I simply generated the TeX output on my machine and took a screenshot. Aug 1, 2013 at 11:34

I think pgfplots can be used here, but you need to take an ad-hoc approach.

If I understand the problem correctly, the restriction of your set to [0,m]^3 (where m is some nonnegative value) corresponds the union of the convex hulls of three triangles:

• (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)

My approach was to draw those three triangles separately with one \addplot3 each, using the patch and patch type=triangle keys. To get nice colours, I change the colormap for each plot; there's probably a better way of doing that...

\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},
]
coordinates {
(0,0,0) (\xmax,\xmax,0) (\xmax,\xmax,\xmax)
};
coordinates {
(0,0,0) (\xmax,0,\xmax) (\xmax,\xmax,\xmax)
};
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}


Edit: A more elegant alternative in 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}