Hi, this post is about having multiple y variables in a single scatter plot. The data we will be using is the English Premier league 2021-2022 season table. Below is the video, source code and the Excel file for the Premier League table.
season = "2021_2022"
main_folder_2 = "C:\\Users\\abcdef\\Documents\\Algo\\1_EPL\\AA_Table"
folder_name_2 = main_folder_2 + "\\Table_{}".format(season)
file_name_2 = folder_name_2 + "\\Table_{}.xlsx".format(season)
X_2 = "team"
y_2 = "for_home"
y_2_2 = "against_home"
y_3 = "for_away"
y_3_3 = "against_away"
df_2 = pd.read_excel(file_name_2)
#df_2.shape
#df_2.describe()
#df_2.head()
#df_2.hist(column='goals');
# Draw a scatter plot
table_plot = df_2.plot.scatter(x = X_2, y = y_2, s = 50, color='g', label = y_2, figsize=(20, 4,), rot = 45);
table_plot_2 = df_2.plot.scatter(x = X_2, y = y_2_2, s = 50, color='r', label = y_2_2, ax = table_plot, rot = 45);
table_plot_3 = df_2.plot.scatter(x = X_2, y = y_3, s = 50, color='g', marker = "x", label = y_3, ax = table_plot, rot = 45);
table_plot_4 = df_2.plot.scatter(x = X_2, y = y_3_3, s = 50, color='r', label = y_3_3, marker = "x", ax = table_plot, rot = 45);
table_plot.grid(axis='y')
table_plot.set_xlabel('Team')
table_plot.set_ylabel('For and Against goals (home and away)')
