# 3d plot of a surface with nonrectangular domain

I need to make a 3D plot of a step function

For example, suppose that I want to plot the function f:[0,1]x[0,1]->[0,1] given by:

f(x,y) = 1 if x < y^2 and f(x,y) = 0 otherwise

I would like to use a LaTeX solution (preferably pstricks, but tikz is fine) instead of importing a figure from Asymptote

I couldn't find a solution using pst-3dplot, is there a package with a pre-build solution to plot his kind of functions?

## 1 Answer

I don't know what kind of a surface rendition you have in mind but you can do it in pgfplots, say, via surfaces.

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=0:1, y domain=0:1,samples=20,no marks]
\addplot3+[surf,colormap/blackwhite](x,y,{(x < y^2?1:0)});
\end{axis}
\end{tikzpicture}
\end{document}


• Thank you, do you know if there is a pstricks package that does the same? – brunosalcedo Mar 9 '17 at 1:28