ML#03 - Matplotlib
ML#03 - Matplotlib
pyplot as plt
import numpy as np
import pandas as pd
#1. Write a Python program to plot two or more lines on same plot with
suitable legends of each line.
<matplotlib.legend.Legend at 0x2d814877a20>
#2. Write a Python program to plot two or more lines with legends,
different widths and colors.
<matplotlib.legend.Legend at 0x2d81493c5f8>
plt.minorticks_on()
plt.grid(which='major', linestyle='-', linewidth='0.5', color='red')
plt.grid(which='minor', linestyle=':', linewidth='0.5', color='black')
plt.show()
#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]
plt.show()
#4. Write a Python programming to create a pie chart of the popularity
of
#programming Languages.
# 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)
plt.show()