Page 498 - AI Ver 3.0 class 10_Flipbook
P. 498
20. Using Matplotlib and the given data, Plot a pie chart:
Data=[45,23,41,78,65]
Ans. [1]: from matplotlib import pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
ax.axis('equal')
Data=[45,23,41,78,65]
ax.pie(Data,autopct='%1.2f%%')
plt.show()
9.13%
16.27%
17.86%
30.95%
25.79%
21. Using Matplotlib and the given data, plot a scatter chart:
Height = [4.5,5.2,4.1,3.5,5]
Weight = [34,41,45,56,39]
Ans. [1]: import matplotlib.pyplot as plt
Weight = [34,41,45,56,39]
Height = [4.5,5.2,4.1,3.5,5]
plt.scatter(Height, Weight, c='blue')
plt.title('Scatter plot')
plt.xlabel('Height')
plt.ylabel('Weight')
plt.show()
Scatter plot
55
50
Weight 45
40
35
3.50 3.75 4.00 4.25 4.50 4.75 5.00 5.25
Height
496 Touchpad Artificial Intelligence (Ver. 3.0)-X

