11/5/24 For more free, peer-reviewed, openly licensed resources visit OpenStax.org. 1
, Principles of Data Science
Chapter 9
Visualizing Data
Critical Thinking
[9.1, LO 9.1.1]
1.
a. For the following five-number summary of a dataset of textbook cost per student per
semester, create a horizontal boxplot.
Minimum=$ 83 First Quartile=$ 255 Median=$ 481Third Quartile=$ 604 Maximum=$ 793
b. Analyze the boxplot and comment on variability, symmetry, and skewness.
Solution a:
Python code:
# import matplotlib
import matplotlib.pyplot as plt
import numpy as np
# Given values for the five-number summary
minimum = 83
q1 = 255
median = 481
q3 = 604
maximum = 793
# Create a boxplot using the given values
plt.boxplot([[minimum, q1, median, q3, maximum]], vert=False,
widths=0.1)
# Add labels and title
plt.xlabel('Textbook Cost ($)')
plt.title('Boxplot Showing Textbook Cost per Student per
Semester')
# Show the plot
plt.show()
11/5/24 For more free, peer-reviewed, openly licensed resources visit OpenStax.org. 2