Question: ***Sub-Plots using Matplotlib*** Using the three(3) plots from above, plot them as subplots with 3 ROWS and 1 COLUMN REF: https://www.w3schools.com/python/matplotlib_subplot.asp 1. Set figsize to
***Sub-Plots using Matplotlib***
Using the three(3) plots from above, plot them as subplots with 3 ROWS and 1 COLUMN
REF: https://www.w3schools.com/python/matplotlib_subplot.asp
1. Set figsize to (10,10) 2. Create first with the row = 3; column = 1, and index 1 - Set line color red - Add title Total Viewers (1000's) - Add a full grid 3. Create second subplot with the row = 3; column = 1, and index 2 - Set line color blue - Add title Average Viewers (1000's) - Add a full grid 4. Create third subplot with the row = 3; column = 1, and index 3 - Set scatter plot points the color green - Add title Ratings 5. Show the plots
***THESE ARE THE 3 PLOTS FOR REFERENCE***
PLOT 1:
# Creating an array containing TOT_viewers values TOTALVIEWERS = DF_SUPERBOWL['TOT_viewers'].values TOTAL_1K = TOTALVIEWERS / 1000 # Create a line plot with a title and axis labels plt.title('Superbowl - Total Viewers') plt.xlabel('Superbowl Number') plt.ylabel('Total Viewers (in 1000s)') plt.plot(TOTAL_1K) plt.show()
PLOT 2: USE AVERAGE_1K
AVGVIEWERS = DF_SUPERBOWL['AVG_viewers'].values AVERAGE_1K = AVGVIEWERS / 1000 plt.title('Superbowl - Viewers',fontsize=15, fontweight='bold' ) plt.xlabel('Superbowl Number') plt.ylabel('Viewers(in 1000s)') plt.plot(TOTAL_1K, label='Total Viewers') plt.plot(AVERAGE_1K, label='Average Viewers') plt.legend() plt.show()
PLOT 3:
X_VALUES = [i for i in range(55)] RATING = np.array(DF_SUPERBOWL['Rating']) Y_VALUES = list(RATING) plt.scatter(X_VALUES, Y_VALUES) plt.title('SuperBowl Ratings', fontsize= 12, fontweight='bold') plt.xlabel('Superbowl Number') plt.ylabel('Ratings') plt.grid() plt.show()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
