Challenge - 5 Problems
3D Wireframe Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a simple 3D wireframe plot code
What will be the output of the following code snippet that creates a 3D wireframe plot?
Matplotlib
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x = np.linspace(-5, 5, 10) y = np.linspace(-5, 5, 10) X, Y = np.meshgrid(x, y) Z = np.sin(np.sqrt(X**2 + Y**2)) ax.plot_wireframe(X, Y, Z) plt.show()
Attempts:
2 left
💡 Hint
Think about what plot_wireframe does with meshgrid data in 3D.
✗ Incorrect
The code creates a 3D wireframe plot of the function sin(sqrt(x^2 + y^2)), which looks like circular waves radiating from the center.
❓ data_output
intermediate2:00remaining
Number of lines in a 3D wireframe plot
Given the following code, how many wireframe lines will be drawn along the X and Y directions respectively?
Matplotlib
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D x = np.linspace(0, 1, 15) y = np.linspace(0, 1, 10) X, Y = np.meshgrid(x, y) Z = X * Y fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_wireframe(X, Y, Z) plt.show()
Attempts:
2 left
💡 Hint
The number of lines corresponds to the number of points in each meshgrid dimension.
✗ Incorrect
The meshgrid creates 15 points along X and 10 points along Y, so the wireframe draws 10 lines along X and 15 lines along Y.
🔧 Debug
advanced2:00remaining
Identify the error in 3D wireframe plot code
What error will this code produce when run, and why?
Matplotlib
import numpy as np import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x = np.linspace(-3, 3, 20) y = np.linspace(-3, 3, 20) X, Y = np.meshgrid(x, y) Z = np.sin(X) + np.cos(Y) ax.plot_wireframe(X, Y, Z) plt.show()
Attempts:
2 left
💡 Hint
Check if the projection='3d' is correctly set and if the imports are sufficient.
✗ Incorrect
The code imports matplotlib.pyplot and numpy correctly, uses fig.add_subplot with projection='3d', so ax is a 3D axes object with plot_wireframe method. No error occurs.
❓ visualization
advanced2:00remaining
Effect of changing stride parameters in wireframe plot
What is the visual effect of changing the stride parameters in the plot_wireframe method as shown below?
Matplotlib
import numpy as np import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x = np.linspace(-5, 5, 50) y = np.linspace(-5, 5, 50) X, Y = np.meshgrid(x, y) Z = np.sin(np.sqrt(X**2 + Y**2)) ax.plot_wireframe(X, Y, Z, rstride=10, cstride=5) plt.show()
Attempts:
2 left
💡 Hint
rstride controls row spacing, cstride controls column spacing of wireframe lines.
✗ Incorrect
rstride=10 means every 10th row is drawn, so lines are spaced sparsely along rows; cstride=5 means every 5th column is drawn, so lines are denser along columns.
🚀 Application
expert3:00remaining
Using 3D wireframe plots to analyze terrain elevation data
You have elevation data of a terrain stored in a 2D numpy array `elevation` with shape (100, 100). Which code snippet correctly creates a 3D wireframe plot of this terrain assuming x and y coordinates range from 0 to 10?
Attempts:
2 left
💡 Hint
Remember that meshgrid creates X and Y with shape matching (len(y), len(x)) and elevation shape must align accordingly.
✗ Incorrect
np.meshgrid(x, y) creates X and Y with shape (100, 100) matching the elevation array shape (100, 100). The indexing aligns such that elevation[i,j] corresponds to the position (X[i,j], Y[i,j]), so no transposition is needed.