0
0
Data Analysis Pythondata~10 mins

Figure and axes creation in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Figure and axes creation
📖 Scenario: You are working as a data analyst. You want to create a simple plot to visualize some data. Before plotting, you need to create a figure and axes using a popular plotting library.
🎯 Goal: Create a figure and axes using matplotlib.pyplot so you can later add plots to the axes.
📋 What You'll Learn
Import matplotlib.pyplot as plt
Create a figure and axes using plt.subplots()
Store the figure in a variable called fig
Store the axes in a variable called ax
💡 Why This Matters
🌍 Real World
Creating figures and axes is the first step in visualizing data in many data science projects.
💼 Career
Data analysts and scientists often create plots to explore and communicate data insights clearly.
Progress0 / 4 steps
1
Import matplotlib.pyplot
Write the import statement to import matplotlib.pyplot as plt.
Data Analysis Python
Hint

Use the syntax import matplotlib.pyplot as plt to import the plotting library.

2
Create figure and axes
Create a figure and axes using plt.subplots(). Assign the figure to a variable called fig and the axes to a variable called ax.
Data Analysis Python
Hint

Use fig, ax = plt.subplots() to create the figure and axes.

3
Check figure and axes types
Write code to print the types of fig and ax using the type() function.
Data Analysis Python
Hint

Use print(type(fig)) and print(type(ax)) to see their types.

4
Display the empty figure
Use the plt.show() function to display the empty figure you created.
Data Analysis Python
Hint

Call plt.show() to open a window with the empty plot.