0
0
Matplotlibdata~20 mins

Dashboard layout patterns in Matplotlib - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Dashboard Layout Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
visualization
intermediate
2:00remaining
Identify the correct subplot layout for a 2x2 dashboard

You want to create a dashboard with 4 charts arranged in 2 rows and 2 columns using matplotlib. Which code snippet correctly creates this layout?

A
fig, axs = plt.subplots(2, 2)
axs[0, 0].plot(data1)
axs[0, 1].plot(data2)
axs[1, 0].plot(data3)
axs[1, 1].plot(data4)
B
fig, axs = plt.subplots(4, 1)
axs[0].plot(data1)
axs[1].plot(data2)
axs[2].plot(data3)
axs[3].plot(data4)
C
fig, axs = plt.subplots(3, 3)
axs[0, 0].plot(data1)
axs[0, 1].plot(data2)
axs[1, 0].plot(data3)
axs[1, 1].plot(data4)
D
fig, axs = plt.subplots(1, 4)
axs[0].plot(data1)
axs[1].plot(data2)
axs[2].plot(data3)
axs[3].plot(data4)
Attempts:
2 left
💡 Hint

Think about how many rows and columns you need and how matplotlib returns axes in a 2D array for multiple rows and columns.

🧠 Conceptual
intermediate
1:30remaining
Best practice for dashboard layout to improve readability

Which of the following is the best practice to improve readability in a dashboard layout?

AGroup related charts together and use consistent spacing
BPlace all charts in a single row to avoid scrolling
CUse as many colors as possible to differentiate charts
DMake charts as small as possible to fit more on screen
Attempts:
2 left
💡 Hint

Think about how grouping and spacing affect how easily someone can understand the dashboard.

dax_lod_result
advanced
2:30remaining
Calculate total sales per region ignoring filters on product category

Given a sales table with columns Region, ProductCategory, and SalesAmount, which DAX measure calculates total sales per region ignoring any filters on ProductCategory?

ATotal Sales by Region = CALCULATE(SUM(Sales[SalesAmount]), REMOVEFILTERS(Sales[Region]))
BTotal Sales by Region = SUM(Sales[SalesAmount])
CTotal Sales by Region = CALCULATE(SUM(Sales[SalesAmount]), ALL(Sales[ProductCategory]))
DTotal Sales by Region = CALCULATE(SUM(Sales[SalesAmount]), ALL(Sales[Region]))
Attempts:
2 left
💡 Hint

Use a function that removes filters on ProductCategory but keeps filters on Region.

🔧 Debug
advanced
2:00remaining
Identify the error in this matplotlib dashboard layout code

What error will this code produce when creating a 3x1 dashboard layout?

fig, axs = plt.subplots(3, 1)
axs[0, 0].plot(data1)
axs[1, 0].plot(data2)
axs[2, 0].plot(data3)
Matplotlib
fig, axs = plt.subplots(3, 1)
axs[0, 0].plot(data1)
axs[1, 0].plot(data2)
axs[2, 0].plot(data3)
ANo error, code runs correctly
BTypeError: 'AxesSubplot' object is not subscriptable
CAttributeError: 'list' object has no attribute 'plot'
DIndexError: index 1 is out of bounds for axis 0 with size 1
Attempts:
2 left
💡 Hint

Check how matplotlib returns axes when there is only one column.

🎯 Scenario
expert
3:00remaining
Design a responsive dashboard layout for different screen sizes

You are designing a dashboard that must look good on both desktop and mobile screens. Which approach best supports responsive layout using matplotlib?

ACreate one large figure and rely on zooming to view details on smaller screens
BUse <code>plt.subplots()</code> with fixed rows and columns and resize the figure manually
CCreate separate figures for desktop and mobile and switch based on screen size
DUse a flexible grid layout with <code>GridSpec</code> and adjust subplot sizes dynamically
Attempts:
2 left
💡 Hint

Think about how to adjust layout dynamically rather than fixed sizes.