0
0
Pandasdata~20 mins

Plot customization (title, labels, figsize) in Pandas - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Plot Customization Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the size of the plot created by this code?
Consider this code that creates a plot with pandas. What is the size of the figure in inches?
Pandas
import pandas as pd
import matplotlib.pyplot as plt

data = {'A': [1, 3, 2, 4]}
df = pd.DataFrame(data)

ax = df.plot(figsize=(8, 4))
plt.close()  # Close plot to avoid display
A[6, 6]
B[4, 8]
C[8, 4]
D[10, 5]
Attempts:
2 left
💡 Hint
The figsize parameter expects a tuple (width, height) in inches.
Predict Output
intermediate
2:00remaining
What is the title of the plot after running this code?
This code creates a plot and sets a title. What will be the exact title shown on the plot?
Pandas
import pandas as pd
import matplotlib.pyplot as plt

data = {'B': [5, 2, 7, 1]}
df = pd.DataFrame(data)

ax = df.plot()
ax.set_title('Sales Over Time')
plt.close()
ASales Over Time
Bsales over time
CSales over time
DSALES OVER TIME
Attempts:
2 left
💡 Hint
Titles are case sensitive and appear exactly as set.
data_output
advanced
2:00remaining
What are the x and y axis labels after this code runs?
This code sets labels for x and y axes. What are the labels shown on the plot axes?
Pandas
import pandas as pd
import matplotlib.pyplot as plt

data = {'C': [10, 20, 15, 25]}
df = pd.DataFrame(data)

ax = df.plot()
ax.set_xlabel('Month')
ax.set_ylabel('Revenue')
plt.close()
Ax label: Month, y label: Revenue
Bx label: revenue, y label: month
Cx label: Month, y label: month
Dx label: Revenue, y label: Month
Attempts:
2 left
💡 Hint
Labels are set exactly by set_xlabel and set_ylabel methods.
visualization
advanced
2:00remaining
Which option shows the correct plot title and axis labels after this code?
This code creates a plot with a title and axis labels. Which option correctly describes the plot's title and labels?
Pandas
import pandas as pd
import matplotlib.pyplot as plt

data = {'D': [3, 6, 9, 12]}
df = pd.DataFrame(data)

ax = df.plot(figsize=(5, 3))
ax.set_title('Quarterly Growth')
ax.set_xlabel('Quarter')
ax.set_ylabel('Growth (%)')
plt.close()
ATitle: quarterly growth, X label: Growth (%), Y label: Quarter
BTitle: Quarterly Growth, X label: Quarter, Y label: Growth (%)
CTitle: Quarterly Growth, X label: Growth (%), Y label: Quarter
DTitle: Growth Quarterly, X label: Quarter, Y label: Growth (%)
Attempts:
2 left
💡 Hint
Check the exact strings used in set_title, set_xlabel, and set_ylabel.
🔧 Debug
expert
2:00remaining
What error does this code raise when trying to set the plot size?
This code tries to set the figure size but causes an error. What is the error type?
Pandas
import pandas as pd
import matplotlib.pyplot as plt

data = {'E': [1, 2, 3, 4]}
df = pd.DataFrame(data)

ax = df.plot(figsize=[6, 4])
plt.close()
ATypeError
BValueError
CAttributeError
DNo error, runs fine
Attempts:
2 left
💡 Hint
Check if figsize accepts list or tuple.