Professional Documents
Culture Documents
PRACTICAL FILE
Name: Zaid Kesarani
Semester: IV
Matrix Multiplication
Q.2 Reading image file and converting RGB to gray image.
Q.3 Plotting line graph and circle using python and other
graphics libraries.
defplotCircle(radius):
circle = patches.Circle((0,0), radius ,facecolor ='red',edgecolor =
'green',linestyle='dotted',linewidth='2.2')
plt.gca().add_patch(circle)
plt.axis('scaled')
plt.title('circle')
plt.show()
def main():
radius=float(input('enter the radius:'))
plotCircle(radius)
if __name__ == '__main__' :
main()
def plotEllipse(width,height):
ellipse= patches.Ellipse((0,0), width,height, angle=15, fc='cyan',
ec='red',linestyle='dashed',lw='2.2')
plt.gca().add_patch(ellipse)
plt.axis('scaled')
plt.title('ellipse')
plt.show()
def main():
width=float(input('enter the width:'))
height=float(input('enter the height:'))
plotEllipse(width,height)
if __name__ == '__main__' :
main()
def plotRectangle(length,breadth):
rect=patches.Rectangle((0,0),length,breadth)
plt.gca().add_patch(rect)
plt.axis('scaled')
plt.title('Rectangle')
plt.show()
def main():
length=float(input('enter the length:'))
breadth=float(input('enter the breadth:'))
plotRectangle(length,breadth)
if __name__ == '__main__' :
main()
def plotPolygon(points):
poly = patches.Polygon(points,ec='red',linestyle='dashed',lw='4')
plt.gca().add_patch(poly)
plt.axis('scaled')
plt.title('polygon')
plt.show()
def main():
points=eval(input('enter the points:'))
plotPolygon(points)
if __name__ == '__main__':
main()