0
0
Matplotlibdata~20 mins

Why statistical plots reveal data patterns in Matplotlib - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Statistical Plot Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
visualization
intermediate
2:00remaining
Identify the pattern shown by this scatter plot

Look at the scatter plot created by the code below. What pattern does it show about the relationship between x and y?

Matplotlib
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(0)
x = np.arange(10)
y = 2 * x + np.random.normal(0, 1, 10)

plt.scatter(x, y)
plt.title('Scatter plot of x vs y')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
ANo clear pattern; points are randomly scattered
BA negative linear trend where y decreases as x increases
CA positive linear trend where y increases as x increases
DA curved pattern showing a quadratic relationship
Attempts:
2 left
💡 Hint

Look at how the points move as x gets bigger. Do they go up, down, or stay random?

data_output
intermediate
1:30remaining
Count of categories shown by a bar plot

Given the code below that plots a bar chart of fruit counts, how many total fruits are counted?

Matplotlib
import matplotlib.pyplot as plt
fruits = ['apple', 'banana', 'orange', 'apple', 'banana', 'apple']

from collections import Counter
counts = Counter(fruits)

plt.bar(counts.keys(), counts.values())
plt.title('Fruit counts')
plt.show()

print(sum(counts.values()))
A3
B9
C2
D6
Attempts:
2 left
💡 Hint

Count how many fruits are in the list, not just unique types.

Predict Output
advanced
2:00remaining
Output of histogram bin counts

What is the output of the following code that creates a histogram and prints the bin counts?

Matplotlib
import matplotlib.pyplot as plt
import numpy as np

data = np.array([1, 2, 2, 3, 5, 5, 5, 5, 6])
counts, bins, patches = plt.hist(data, bins=3)
plt.close()
print(counts)
A[2. 3. 4.]
B[3. 1. 5.]
C[3. 3. 3.]
D[1. 4. 4.]
Attempts:
2 left
💡 Hint

Check how the data values fall into 3 equal bins between min and max.

🧠 Conceptual
advanced
1:30remaining
Why box plots reveal data spread and outliers

Which statement best explains why box plots help reveal data patterns?

ABox plots summarize data distribution by showing median, quartiles, and outliers
BBox plots show the exact value of every data point in the dataset
CBox plots only show the mean and ignore data spread
DBox plots are used to display relationships between two variables
Attempts:
2 left
💡 Hint

Think about what parts of the data a box plot highlights.

🔧 Debug
expert
1:30remaining
Identify the error in this code plotting a line chart

What error does the following code produce when run?

Matplotlib
import matplotlib.pyplot as plt
x = [1, 2, 3]
y = [4, 5]
plt.plot(x, y)
plt.show()
AValueError: x and y must have same first dimension
BTypeError: 'list' object is not callable
CSyntaxError: invalid syntax
DNo error; plot displays correctly
Attempts:
2 left
💡 Hint

Check if x and y lists have the same length.