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

Worksheet On Matplotlib

The document provides practical questions for using Matplotlib in Python, including tasks such as plotting line graphs, bar charts, pie charts, scatter plots, and histograms. Each task specifies the data to be used and the required features like titles, labels, legends, and color variations. The document serves as a guide for practicing data visualization techniques with 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)
5 views2 pages

Worksheet On Matplotlib

The document provides practical questions for using Matplotlib in Python, including tasks such as plotting line graphs, bar charts, pie charts, scatter plots, and histograms. Each task specifies the data to be used and the required features like titles, labels, legends, and color variations. The document serves as a guide for practicing data visualization techniques with 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

PRACTICAL QUESTIONS ON MATPLOTLIB

1. Plot a simple line graph

Write a Python program using matplotlib to plot:

• x = [1, 2, 3, 4]
• y = [2, 4, 1, 5]
Add labels and a title.

2. Plot two lines on the same graph

Write a Python program using matplotlib to plot two-line plots:

• Line 1: x=[1,2,3], y=[1,4,9]


• Line 2: x=[1,2,3], y=[2,3,6]
Add legend.

3. Bar chart of student marks

Write a Python program using matplotlib to create a vertical bar chart.

Add:

• Title
• X and Y labels
• Different bar colors

Given:

subjects = ['Math', 'Science', 'English']


marks = [88, 92, 79]

4. Horizontal bar chart

Create a horizontal bar chart for:

languages = ['Python','Java','C++']
popularity = [60, 45, 30]

5. Pie chart

Create a pie chart of:

• ['Apple', 'Samsung', 'Xiaomi']


• [50, 30, 20]
Add:
• Percentage labels
• Title
• Explode one slice
6. Scatter plot

Plot a scatter plot of:

height = [150, 160, 170, 180]


weight = [50, 60, 72, 85]

Add color & size variation.

7. Histogram

Plot a histogram of marks:

marks = [56, 78, 45, 89, 90, 65, 74, 88, 92, 58]

You might also like