Matplotlib Assignment
1. In order to assess the performance of students of a class in the annual
examination, the class teacher stored marks of the students in all the 5 subjects in
a CSV “[Link]” file as shown in Table. Plot the data using boxplot and
perform a comparative analysis of performance in each subject.
2. Prayatna sells designer bags and wallets. During the sales season, he offered
discounts ranging from 10% to 50% over a period of 5 weeks. He recorded his
sales for each discount rate in an array as follows:
Discounts (%) = [10, 20, 30, 40, 50]
Sales (in Rs.) = [40000, 45000, 48000, 50000, 100000].
Draw a scatter plot to show the relationship between the discount offered and the
sales made.
3. Analyze and visualize automobile fuel efficiency Auto MPG dataset using
`pandas` for data manipulation and `matplotlib` for plotting.
Dataset URL: `[Link]
mpg/[Link]`
Column Names: ['mpg', 'cylinders', 'displacement', 'horsepower', 'weight',
'acceleration', 'model_year', 'origin', 'car_name']
a. Data Loading and Cleaning
Load the dataset using `pandas`.
Assign proper column names.
Handle missing values (hint: some rows have '?' in the `horsepower`
column).
Convert the `horsepower` column to numeric type.
b. Scatter Plot: Horsepower vs MPG
Create a scatter plot showing the relationship between “horsepower” and
“mpg”.
Label the axes and title the plot appropriately.
Use grid lines for better readability.
c. Histogram: Distribution of MPG
Plot a histogram to show the frequency distribution of the `mpg` (miles per
gallon).
Use appropriate number of bins (e.g., 15–20).
Label the axes and add a title.
d. Box Plot: (MPG by Cylinders)
Create a box plot showing the distribution of “mpg” grouped by the number
of “cylinders”.
Each box should represent one cylinder group (e.g., 4, 6, 8).
Add axis labels and a title.