0% found this document useful (0 votes)
106 views2 pages

Matplotlib Practice Questions

The document contains practice questions for using Matplotlib in Python, including creating a line plot, bar chart, histogram, pie chart, and box plot. Each question provides sample code for visualizing data such as scores and time spent on activities. The examples demonstrate basic plotting techniques and customization options available in Matplotlib.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views2 pages

Matplotlib Practice Questions

The document contains practice questions for using Matplotlib in Python, including creating a line plot, bar chart, histogram, pie chart, and box plot. Each question provides sample code for visualizing data such as scores and time spent on activities. The examples demonstrate basic plotting techniques and customization options available in Matplotlib.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Matplotlib - Practice Questions

Q1. Write a Python program to create a line plot for the following two lists:
import [Link] as plt

x = [1, 2, 3, 4, 5]
y = [2, 4, 1, 5, 7]

[Link](x, y, label='Sample Line', color='red', linestyle='--', marker='o',


linewidth=2)
[Link]('X Axis')
[Link]('Y Axis')
[Link]('Line Plot Example')
[Link]()
[Link]()
[Link]()

Q2. Write a Python program to create a bar chart for the following data:
import [Link] as plt

categories = ['Math', 'Science', 'English', 'History']


scores = [88, 92, 81, 76]

[Link](categories, scores, label='Scores')


[Link]('Subjects')
[Link]('Scores')
[Link]('Student Score')
[Link]()
[Link]()

Q3. Write a Python program to create a histogram to show the distribution of scores using 5

bins:
import [Link] as plt

scores = [70, 72, 74, 76, 76, 78, 80, 82, 84, 84, 85, 88, 90, 92, 95]
[Link](scores, bins=5, edgecolor='black')
[Link]('Score Ranges')
[Link]('Number of Students')
[Link]('Score Distribution')
[Link]()

Q4. Write a Python program to create a pie chart showing percentage of time spent on

activities:
import [Link] as plt

activities = ['Sleep', 'Study', 'Exercise', 'Leisure']


hours = [8, 6, 2, 8]

[Link](hours, labels=activities, autopct='%1.1f%%')


[Link]('Daily Time Spent on Activities')
[Link]()

Q5. Write a Python program to create a box plot for the following data:
import [Link] as plt

data = [75, 80, 85, 90, 90, 92, 95, 100, 100, 105, 110]

[Link](data)
[Link]('Box Plot of Scores')
[Link]('Data Set')
[Link]('Score')
[Link]()

You might also like