|
80 | 80 | axes[2,1].set_title('Box-and-Whisker') |
81 | 81 | plt.tight_layout() # prevent plot overlap |
82 | 82 |
|
| 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 | + |
83 | 106 | # Set x- and y-axis for each subplot |
84 | 107 | import matplotlib.pyplot as plt |
85 | 108 | fig, axes = plt.subplots(nrows=3, ncols=2) |
|
0 commit comments