0
0
Matplotlibdata~5 mins

Figure creation with plt.figure in Matplotlib - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does plt.figure() do in matplotlib?

plt.figure() creates a new figure window or canvas where you can draw your plots. Think of it as a blank sheet of paper to draw on.

Click to reveal answer
beginner
How can you set the size of a figure using plt.figure()?

You can set the size by passing the figsize argument as a tuple of width and height in inches, like plt.figure(figsize=(8, 5)).

Click to reveal answer
intermediate
What is the default behavior if you call plt.figure() multiple times without showing or saving the figure?

Each call creates a new figure. If you don't show or save them, they stay in memory but are not visible until you call plt.show().

Click to reveal answer
intermediate
How do you give a figure a custom title or name using plt.figure()?

You can use the num parameter to name the figure window, for example plt.figure(num='My Plot').

Click to reveal answer
beginner
Why might you want to create multiple figures in matplotlib?

Creating multiple figures lets you work on different plots separately, like having multiple sheets of paper to compare or save different charts.

Click to reveal answer
What does plt.figure(figsize=(6,4)) do?
ACreates 6 figures and 4 subplots
BCreates a figure with 6 rows and 4 columns
CCreates a figure 6 inches wide and 4 inches tall
DSets the font size to 6 and line width to 4
Which command creates a new blank figure in matplotlib?
Aplt.subplot()
Bplt.plot()
Cplt.show()
Dplt.figure()
How can you name a figure window in matplotlib?
AUsing <code>plt.title()</code>
BUsing <code>plt.figure(num='Name')</code>
CUsing <code>plt.xlabel()</code>
DUsing <code>plt.legend()</code>
What happens if you call plt.figure() twice without showing the plot?
ATwo separate figures are created but not shown
BAn error occurs
COnly one figure is created
DThe second call overwrites the first figure
Why use multiple figures in matplotlib?
ATo plot multiple charts separately
BTo speed up plotting
CTo change colors automatically
DTo save memory
Explain how to create a new figure with a specific size and name using plt.figure().
Think about how to set width, height, and window title.
You got /4 concepts.
    Describe why creating multiple figures can be useful when making plots.
    Imagine working on different drawings on separate sheets.
    You got /4 concepts.