Professional Documents
Culture Documents
8.2 6. Plotting Subplots
8.2 6. Plotting Subplots
Subplots
Mutilple plots within a single figure are called Subplots.
# plt.subplots()
# Pie Plot
# Stack Plot
# Histogram
X = [41, 35, 58, 45, 81, 56, 73, 63, 20, 0, 38, 22, 42, 31, 15] # Scores of players in a T20 game
bins=[0,10,20,30,40,50,60,70,80,90,100,110,120]
df = pd. read_csv('class.csv')
group=df.groupby (['Age'])
df1=group.mean()
df1
width=.40
# Line Chart
fig, ax = plt.subplots (nrows=3, ncols=2, figsize=(10, 10)) # Use figsize=(10, 10) to change the figure size
# Pie Plot
# Stack Plot
ax[0,1].stackplot (days, sleeping, working, Travel, eating, labels=label, colors=['#ff8000', '#00cc00', '#ffff00'
# Histogram
for x, y in zip(df1.index,df1['Height']):
ax[1,1].text(x, y, str(int(y)), color='Black', fontweight='bold')
for x, y in zip(df1.index,df1['Weight']):
ax[1,1].text(x, y, str(int(y)), color='Black', fontweight='bold')
# Scatter Plot
ax[2,0].scatter(df["Height"],df["Weight"],color='b',marker='*',label='Height vs Weight',s=100)
# Line Chart
fig. tight_layout (pad=3) # Using pad= option will add gaps between the images
Loading [MathJax]/jax/output/CommonHTML/fonts/TeX/fontdata.js