0
0
Matplotlibdata~30 mins

3D scatter plots in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
3D Scatter Plots
📖 Scenario: You are a data analyst working with a dataset of points in 3D space. You want to visualize these points to understand their distribution and relationships.
🎯 Goal: Create a 3D scatter plot using matplotlib to visualize the points in three dimensions.
📋 What You'll Learn
Create three lists named x, y, and z with the exact values provided.
Create a variable color to specify the color of the points.
Use matplotlib to create a 3D scatter plot with the given data and color.
Display the plot using plt.show().
💡 Why This Matters
🌍 Real World
3D scatter plots help scientists and engineers visualize data points in three dimensions, such as geographic locations, sensor data, or experimental results.
💼 Career
Data analysts and data scientists use 3D scatter plots to explore complex datasets and communicate insights visually to teams and stakeholders.
Progress0 / 4 steps
1
Create the 3D data points
Create three lists called x, y, and z with these exact values: x = [5, 7, 8, 7, 2, 17, 2, 9, 4, 11], y = [99, 86, 87, 88, 100, 86, 103, 87, 94, 78], and z = [10, 15, 13, 15, 10, 15, 10, 15, 10, 15].
Matplotlib
Need a hint?

Use square brackets to create lists and separate numbers with commas.

2
Set the color for the points
Create a variable called color and set it to the string 'green' to specify the color of the scatter points.
Matplotlib
Need a hint?

Assign the string 'green' to the variable color using the equals sign.

3
Create the 3D scatter plot
Import matplotlib.pyplot as plt and Axes3D from mpl_toolkits.mplot3d. Then create a figure and add a 3D subplot. Use ax.scatter(x, y, z, c=color) to create the 3D scatter plot with the data and color.
Matplotlib
Need a hint?

Use plt.figure() to create a figure and fig.add_subplot(111, projection='3d') to add a 3D plot.

4
Display the 3D scatter plot
Use plt.show() to display the 3D scatter plot.
Matplotlib
Need a hint?

Call plt.show() to open the plot window.