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 1


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

\begin{axis}[domain=0:1, y domain=0:1,samples=20,no marks]
\addplot3+[surf,colormap/blackwhite](x,y,{(x < y^2?1:0)});

enter image description here

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .