Skip to content

Commit c502ec4

Browse files
author
Aaron England
authored
Add files via upload
1 parent d2c091a commit c502ec4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Chapter 5/Activities/Activity_03.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,29 @@
8080
axes[2,1].set_title('Box-and-Whisker')
8181
plt.tight_layout() # prevent plot overlap
8282

83+
# add scatterplot
84+
import matplotlib.pyplot as plt
85+
fig, axes = plt.subplots(nrows=3, ncols=2)
86+
# line plot (top left)
87+
axes[0,0].plot(Items_by_Week['Week'], Items_by_Week['Items_Sold']) # for line plot
88+
axes[0,0].set_title('Line')
89+
# Bar plot (top right)
90+
axes[0,1].bar(Items_by_Week['Week'], Items_by_Week['Items_Sold']) # for bar plot
91+
axes[0,1].set_title('Bar')
92+
# Horizontal bar plot (middle left)
93+
axes[1,0].barh(Items_by_Week['Week'], Items_by_Week['Items_Sold']) # for horizontal bar plot
94+
axes[1,0].set_title('Horizontal Bar')
95+
# Histogram (middle right)
96+
axes[1,1].hist(y, bins=20) # for histogram
97+
axes[1,1].set_title('Histogram')
98+
# Scatterplot (bottom left)
99+
axes[2,0].scatter(Weight_by_Height['Height'], Weight_by_Height['Weight']) # for scatterplot
100+
axes[2,0].set_title('Scatter')
101+
# Box-and-Whisker
102+
axes[2,1].boxplot(y) # for Box-and-Whisker
103+
axes[2,1].set_title('Box-and-Whisker')
104+
plt.tight_layout() # prevent plot overlap
105+
83106
# Set x- and y-axis for each subplot
84107
import matplotlib.pyplot as plt
85108
fig, axes = plt.subplots(nrows=3, ncols=2)

0 commit comments

Comments
 (0)