3

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?

0

1 Answer 1

5

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}

enter image description here

1
  • 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 .