Page 466 - AI Ver 3.0 class 10_Flipbook
P. 466
Brainy Fact
You may create a figure with many plots known as subplots side by side sharing either the same x axis or
same y axis. Following is the code to create 3 subplots with shared y axis
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, sharey=True)
Plotting a Pie chart
It is a circular representation of data where each slice shows the relative size of the data. The data is a complete
circle equal to 360° with each segment and sectors forming a certain portion of the total(percentage).
Matplotlib uses a built-in function - pie() to create pie charts.
Pie chart represents a circle divided into different sectors where each sector represents a part of the whole.
A pie plot is used to represent numerical data proportionally.
[1]: import matplotlib.pyplot as plt
# Data for the pie chart
Temp = [20, 30, 15, 10, 25]
Cities = ['Pune', 'Banglore' , 'Jammu', 'Srinagar' , 'Mumbai' ]
# Creating the pie chart
plt.pie(Temp, labels=Cities, autopct='%1.1f%%')
# Adding title
plt.title('Pie Chart')
# Displaying the pie chart
plt.show()
464 Touchpad Artificial Intelligence (Ver. 3.0)-X

