100% found this document useful (1 vote)
173 views1 page

Python Programs for Charts Using Matplotlib

The document contains Python code for creating a line chart and a scatter chart using matplotlib. It first displays a line chart for the points (2,5) to (9,10) and then a scatter plot comparing the mathematics and science marks of 10 students. The code includes necessary labels and titles for both charts.

Uploaded by

mdyusuff2124
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
100% found this document useful (1 vote)
173 views1 page

Python Programs for Charts Using Matplotlib

The document contains Python code for creating a line chart and a scatter chart using matplotlib. It first displays a line chart for the points (2,5) to (9,10) and then a scatter plot comparing the mathematics and science marks of 10 students. The code includes necessary labels and titles for both charts.

Uploaded by

mdyusuff2124
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

3.

Write a program to display line chart from (2,5) to (9,10):

import [Link] as plt

# Define data points


x = [2, 9] # X-axis points
y = [5, 10] # Y-axis points

# Create the line chart


[Link](x, y)

# Add labels and title


[Link]("X-axis")
[Link]("Y-axis")
[Link]("Line Chart")

# Display the chart


[Link]()

[Link] a program to display a scatter chart for the following points (2,5), (9,10),(8,3),(5,7),(6,18).

Write a Python program to draw a scatter plot comparing two subject marks
of Mathematics and Science. Use marks of 10 students.
Test Data:
math_marks = [88, 92, 80, 89, 100, 80, 60, 100, 80, 34]
science_marks = [35, 79, 79, 48, 100, 88, 32, 45, 20, 30]
marks_range = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
Sample Solution:
Python Code:
import [Link] as plt
import pandas as pd
math_marks = [88, 92, 80, 89, 100, 80, 60, 100, 80, 34]
science_marks = [35, 79, 79, 48, 100, 88, 32, 45, 20, 30]
marks_range = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
[Link](marks_range, math_marks, label='Math marks', color='r')
[Link](marks_range, science_marks, label='Science marks', color='g')
[Link]('Scatter Plot')
[Link]('Marks Range')
[Link]('Marks Scored')
[Link]()
[Link]()

You might also like