0
0
Matplotlibdata~15 mins

Figure creation with plt.figure in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Figure creation with plt.figure
📖 Scenario: You are working on a simple data visualization project. You want to create a blank figure using matplotlib to prepare for adding plots later.
🎯 Goal: Create a blank figure using plt.figure with a specific size.
📋 What You'll Learn
Create a figure using plt.figure
Set the figure size to 6 inches wide and 4 inches tall
Store the figure in a variable called fig
Print the figure object to see its details
💡 Why This Matters
🌍 Real World
Creating figures is the first step in data visualization to prepare a canvas for charts and graphs.
💼 Career
Data scientists and analysts often create and customize figures to present data clearly and attractively.
Progress0 / 4 steps
1
Import matplotlib and create a blank figure
Import matplotlib.pyplot as plt. Then create a blank figure using plt.figure() and store it in a variable called fig.
Matplotlib
Need a hint?

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

Use fig = plt.figure() to create a blank figure.

2
Set the figure size
Modify the plt.figure() call to set the figure size to 6 inches wide and 4 inches tall using the figsize parameter.
Matplotlib
Need a hint?

Use figsize=(6, 4) inside plt.figure() to set the size.

3
Add a title to the figure
Use the fig.suptitle() method to add the title 'My Blank Figure' to the figure.
Matplotlib
Need a hint?

Use fig.suptitle('My Blank Figure') to add a title to the figure.

4
Print the figure object
Print the variable fig to display the figure object details.
Matplotlib
Need a hint?

Use print(fig) to show the figure object details.