A student plots a contour of the paraboloid z=x2+y2z = x^2 + y^2z=x2+y2 on a deliberately coarse grid:
x = np.linspace(-2, 2, 5) y = np.linspace(-2, 2, 5) X, Y = np.meshgrid(x, y) Z = X**2 + Y**2 ax.contour(X, Y, Z, levels=[2])
Matplotlib locates a contour by linear interpolation of Z along the edges between neighbouring grid points. Find:
Unlock full course notes by signing up
Reading a value from a gridded surface
The code below samples a function on a rectangular grid before drawing it with plot_surface.
What value is stored in Z[4, 1]? Give your answer to two decimal places.
Analysing a helix drawn as a 3D line
A student draws a coil spring as a parametric curve on 3D axes. All coordinates are in centimetres.
Find the number of complete turns the curve makes (an integer), the height zzz of the last point in cm to two decimal places, the rise in zzz per turn in cm to two decimal places, and the number of straight line segments ax.plot draws (an integer).
Grid, projection and camera angles for a surface
A student draws the surface z=sinxcosyz = \sin x \cos yz=sinxcosy in Matplotlib. Type each missing name or value as plain text, without any module prefix such as np.
First the student turns the 1D arrays x and y into 2D coordinate grids with the NumPy function ________. They then add axes to the figure with the projection argument set to the string ________.
To look straight down on the surface, as if reading a map, they call view_init with the elevation angle elev set to ________ degrees. To swing the camera around the vertical z-axis instead, they change the other view_init angle, named ________.
Debugging a surface built without a grid
A student wants a surface plot of z=sinxcosyz = \sin x \cos yz=sinxcosy over a rectangle and writes the following code before calling plot_surface.
Which of the following statements about this code and its possible fixes are true? Select all that apply.