> [!Definition] > > Given a [[Real-Valued Function on Real n-Space (Multivariable Function)|real-valued function of two real variables]] $f:U\subseteq \mathbb{R}^{2}\to \mathbb{R}$. The *graph* of $f$ is the [[Algebraic Surface|surface]] in $\mathbb{R}^{3}$ given by $\{ (x,y,z): \forall (x,y) \in U, z=f(x,y) \}.$ > > [!info] > Note we can visualize graphs using [[matplotlib.pyplot]]. # Examples ```run-python import numpy as np import matplotlib.pyplot as plt #%matplotlib x = np.linspace(-1,1) y = np.linspace(-1,1) # Create all pairs (x,y) X, Y = np.meshgrid(x,y) # Function returns 2D array of z values for the pairs (x,y) def zfunc(x,y): return x**2+y**2 fig = plt.figure() ax = fig.add_subplot(projection='3d') ax.set_box_aspect((1,1,1)) # Let's plot the surface # "alpha" adjusts transparency # Choose your favourite colormap ("cmap") here: # https://matplotlib.org/stable/tutorials/colors/colormaps.html ax.plot_surface(X,Y,zfunc(X,Y), alpha =0.7, cmap ='rainbow') ax.set_xlabel('x') ax.set_ylabel('y') ax.set_zlabel('z') # Add a point ax.plot(1,1,2, 'o') # Add text above the point ax.text(1,1,2.1, 'P') plt.show() ```