Challenge - 5 Problems
3D Visualization Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
3D Scatter Plot Output
What will be the output of this Python code using matplotlib for 3D visualization?
Matplotlib
import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x = np.array([1, 2, 3]) y = np.array([4, 5, 6]) z = np.array([7, 8, 9]) ax.scatter(x, y, z) plt.show()
Attempts:
2 left
💡 Hint
Check how the scatter function is used with 3D axes.
✗ Incorrect
The code creates a 3D scatter plot with three points at the given coordinates. The Axes3D import and projection='3d' enable 3D plotting. The scatter method plots points, not lines.
🧠 Conceptual
intermediate1:30remaining
Why Use 3D Visualization?
Which of the following is the best reason to use 3D visualization in data science?
Attempts:
2 left
💡 Hint
Think about what extra dimension adds to data understanding.
✗ Incorrect
3D visualization helps to see how three variables relate to each other in a single view, which is not possible with 2D plots.
🔧 Debug
advanced2:00remaining
Identify the Error in 3D Plot Code
What error will this code produce when run?
Matplotlib
import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(111) x = np.linspace(0, 10, 100) y = np.sin(x) z = np.cos(x) ax.plot(x, y, z) plt.show()
Attempts:
2 left
💡 Hint
Check if the subplot is set for 3D projection.
✗ Incorrect
The subplot is created without 3D projection, so ax.plot expects 2D data. Passing three arrays causes a TypeError.
❓ data_output
advanced1:30remaining
Output of 3D Surface Plot Data
What is the shape of the Z array used in this 3D surface plot code?
Matplotlib
import numpy as np 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))
Attempts:
2 left
💡 Hint
Check the shape of meshgrid outputs.
✗ Incorrect
X and Y are 50x50 grids, so Z computed element-wise has shape (50, 50).
🚀 Application
expert2:30remaining
Choosing 3D Visualization for Complex Data
You have a dataset with four variables: height, weight, age, and income. You want to visualize relationships clearly. Which approach best uses 3D visualization?
Attempts:
2 left
💡 Hint
Think about how to show four variables in one visualization.
✗ Incorrect
Using 3D scatter for three variables and color for the fourth allows visualizing all four variables together effectively.