# Name - Somoydip
# Roll - 23052193
import matplotlib
print(matplotlib.__version__)
3.10.0
import [Link] as plt
import numpy as np
xpoints = [Link]([0, 6])
ypoints = [Link]([0, 250])
[Link](xpoints, ypoints)
[Link]()
xpoints = [Link]([1, 2, 8, 0, 4, 9])
ypoints = [Link]([3, 8, 1, 10, 12, 15])
[Link](xpoints, ypoints, 'o')
[Link]()
# Name - Somoydip
# Roll - 23052193
ypoints = [Link]([3, 8, 1, 10])
[Link](ypoints, 'o-.b', ms = 20, mfc='r')
[Link]()
ypoints = [Link]([3, 8, 1, 10])
[Link](ypoints, linestyle = 'dotted', color = 'hotpink')
[Link]()
font1 = {'family': 'serif', 'color':'blue', 'size': 20}
font2 = {'family': 'serif', 'color':'darkred', 'size': 15}
[Link]("Sports Watch Data", fontdict = font1)
[Link]("Average Pulse", fontdict = font2)
[Link]("Calorie Burnage", fontdict = font2)
# Name - Somoydip
# Roll - 23052193
[Link](x, y, marker = 'o', mfc='r')
[Link](color = 'green', linestyle = '--', linewidth = 1)
[Link]()
x = [Link]([0, 1, 2, 3])
y = [Link]([3, 8, 1, 10])
[Link](2, 3, 1)
[Link](x, y)
x = [Link]([0, 1, 2, 3])
y = [Link]([10, 20, 30, 40])
[Link](2, 3, 2)
[Link](x, y)
x = [Link]([0, 1, 2, 3])
y = [Link]([3, 8, 1, 10])
[Link](2, 3, 3)
[Link](x, y)
x = [Link]([0, 1, 2, 3])
y = [Link]([10, 20, 30, 40])
[Link](2, 3, 4)
[Link](x, y)
# Name - Somoydip
# Roll - 23052193
x = [Link]([0, 1, 2, 3])
y = [Link]([3, 8, 1, 10])
[Link](2, 3, 5)
[Link](x, y)
x = [Link]([0, 1, 2, 3])
y = [Link]([10, 20, 30, 40])
[Link](2, 3, 6)
[Link](x, y)
[Link]()
x = [Link]([5, 7, 8, 7, 2, 17, 9, 4, 11, 12, 9, 6])
y = [Link]([99, 86, 87, 88, 111, 86, 103, 87, 94, 78, 77, 85])
[Link](x, y)
x = [Link]([5, 7, 11, 7, 4, 7, 9, 4, 13, 12, 8, 14])
y = [Link]([102, 86, 66, 88, 111, 99, 103, 87, 103, 78, 77, 85])
[Link](x, y)
[Link]()
# Name - Somoydip
# Roll - 23052193
x = [Link](100, size=(100))
y = [Link](100, size=(100))
colors = [Link](100, size=(100))
sizes = 10 * [Link](100, size=(100))
[Link](x, y, c = colors, s = sizes, alpha = 0.5, cmap =
'nipy_spectral')
<[Link] at 0x237657eafd0>
x = [Link](["A", "B", "C", "D"])
y = [Link]([3, 8, 1, 10])
[Link](x, y)
[Link]()
# Name - Somoydip
# Roll - 23052193
y = [Link]([35, 25, 25, 15])
[Link](y)
[Link]()
[Link](y = 5)
[Link]()
# Name - Somoydip
# Roll - 23052193
# vertical line
[Link](x = 3)
[Link]()
# increase the thickness of a line
x = [1, 2, 3, 4]
y = [2, 4, 1, 5]
[Link](x, y, linewidth=4)
[Link]()
# fill between multiple lines
x = [1, 2, 3, 4]
y1 = [2, 3, 5, 7]
y2 = [1, 2, 3, 4]
[Link](x, y1)
[Link](x, y2)
plt.fill_between(x, y1, y2, alpha=0.3)
[Link]()
# Name - Somoydip
# Roll - 23052193
# horizontal bar chart
names = ['A', 'B', 'C']
values = [10, 25, 15]
[Link](names, values)
[Link]()
# scatter plot with multiple colors
x = [Link](20)
y = [Link](20)
colors = [Link](20)
[Link](x, y, c=colors, cmap='viridis')
[Link]()
[Link]()
# Name - Somoydip
# Roll - 23052193
# increse size of scatter points
[Link](x, y, s = 200)
[Link]()
# connect scatter points with a line
[Link](x, y, '-o')
[Link]()
# Name - Somoydip
# Roll - 23052193
from [Link] import Ellipse
fig, ax = [Link]()
ellipse = Ellipse((0, 0), width = 4, height = 2, fill = False)
ax.add_patch(ellipse)
ax.set_xlim(-5, 5)
ax.set_ylim(-5, 5)
[Link]()
x = [Link](-10, 10, 100)
y = x**2 + 2*x + 1
[Link](x, y)
[Link]()
# Name - Somoydip
# Roll - 23052193
#
change the line opacity
x = [1, 2, 3, 4]
y = [2, 4, 1, 5]
[Link](x, y, alpha=0.4)
[Link]()
# annotate bars in a bar plot
subjects = ['Maths', 'Physics', 'Chemistry']
marks = [78, 85, 69]
bars = [Link](subjects, marks)
for bar in bars:
height = bar.get_height()
[Link](f'{height}',
xy=(bar.get_x() + bar.get_width()/2, height),
xytext=(0, 3),
# Name - Somoydip
# Roll - 23052193
textcoords="offset points",
ha='center', va='bottom')
[Link]()
# annotate bars in a grouped bar plot
subjects = ['Maths', 'Physics', 'Chemistry']
boys = [75, 80, 70]
girls = [85, 90, 78]
x = [Link](len(subjects))
width = 0.35
bars1 = [Link](x - width/2, boys, width, label='Boys')
bars2 = [Link](x + width/2, girls, width, label='Girls')
def annotate(bars):
for bar in bars:
height = bar.get_height()
[Link](f'{height}',
xy=(bar.get_x() + bar.get_width()/2, height),
xytext=(0, 3),
textcoords="offset points",
ha='center', va='bottom')
annotate(bars1)
annotate(bars2)
[Link](x, subjects)
[Link]()
[Link]()
# Name - Somoydip
# Roll - 23052193
# plot a point or a line on an Image with Matplotlib
[Link](img)
[Link](100, 150, color='red') # point
[Link]([50, 200], [60, 180], color='blue') # line
[Link]()
# draw a rectangle on an image in matplotlib
import [Link] as patches
fig, ax = [Link]()
[Link](img)
rect = [Link]((50, 60), 120, 80,
linewidth=2, edgecolor='red',
facecolor='none')
ax.add_patch(rect)
[Link]()
# Name - Somoydip
# Roll - 23052193
# display an OpenCV image
import cv2
import [Link] as plt
img = [Link]('Night [Link]')
img_rgb = [Link](img, cv2.COLOR_BGR2RGB)
[Link](img_rgb)
[Link]('off')
[Link]()
# calculate the area of an image using matplotlib
height, width = [Link][:2]
area = height * width
print("Image Area (in pixels):", area)
Image Area (in pixels): 13500000