In [ ]: import matplotlib.
pyplot as plt
import numpy as np
import pandas as pd
In [2]: #1. Write a Python program to plot two or more lines on same plot with suitable legends
x1 =[Link] ([10, 20, 30])
x2 =[Link] ([10, 20, 30])
y1 = [Link]([20, 40, 10])
y2= [Link] ([40,10, 30]) [Link] ("x-axis") [Link] ("y-axis")
[Link](x1,y1, color= "purple") [Link]( x2, y2, color = "green")
[Link](["Line 1", "Line 2"],loc = "upper right")
<[Link] at 0x2d814877a20>
Out[2]:
In #2. Write a Python program to plot two or more lines with legends, different widths and
[3]:
x1 =[Link] ([10, 20, 30])
x2 =[Link] ([10, 20, 30])
y1 = [Link]([20, 40, 10])
y2= [Link] ([40,10, 30]) [Link] ("x-axis") [Link] ("y-axis")
[Link](x1,y1, color= "blue", linewidth = 3) [Link]( x2, y2, color = "red", linewidth =5)
[Link](["Line 1 width =3", "Line 2 width = 5"],loc = "upper right")
<[Link] at 0x2d81493c5f8>
Out[3]:
In [4]: # Write a Python programming to display a bar chart of the popularity of programming
Lan
x= ['Java', 'Python',' PHP', 'JavaScript', 'C#', 'C+
+'] y= [22.2, 17.6, 8.8, 8, 7.7, 6.7]
[Link]( x,y, color="blue")
[Link](" Programming Languages")
[Link] ("Popularity")
[Link] ("Popularity of programming languages worldwide, Oct 2017 compared to a year
a
plt.minorticks_on()
[Link](which='major', linestyle='-', linewidth='0.5', color='red')
[Link](which='minor', linestyle=':', linewidth='0.5', color='black')
In [5]: #3. Write a Python program to draw a scatter plot comparing two subject marks
of #Mathematics and Science. Use marks of 10 students.
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](math_marks, marks_range, c ="red")
[Link](science_marks, marks_range, c ="green")
[Link](" Marks Range")
[Link] ("Marks
Scored") [Link]
("Scatter Plot")
[Link](["math_marks", "science_marks"],loc = "upper right")
[Link]()
In [13]: #4. Write a Python programming to create a pie chart of the popularity
of #programming Languages.
import [Link] as plt
# Data
programming_languages = ['Java', 'Python', 'PHP', 'JavaScript', 'C#', 'C+
+'] Popularity = [22.2, 17.6, 8.8, 8, 7.7, 6.7]
explode = (0.1, 0, 0, 0, 0, 0) # Explode the second slice (Python)
# Create a pie chart with labels
[Link](Popularity, explode=explode, labels=programming_languages, autopct='%1.1f%%',
shadow=True, startangle=90)
[Link]()
In [ ]: