A visualization of the competition schedule and results (○, △, ●) in a tabular format is called a battle record table. I'll show you the actual graphics because it's just like this.
The way this table looks is that the X-axis shows the opponents to play away and the Y-axis shows the opponents to play at home.
Create such a table from the data of "Schedule-kun" using matplotlib
. This is an example of how you can do this, although it is far from the standard visualization method.
fixturetable.py
game_result = pd.read_csv("../csv/game_result_all_2020_v2.csv", encoding="utf-8")
#J1 team name list (from north) 2020 edition
team = ["Sapporo","Sendai","Kashima","Urawa","oak","FC tokyo","Kawasaki F","Yokohama FM","Yokohama FC","Shonan",
"Shimizu","Nagoya","Gamba Osaka","C Osaka","Kobe","Hiroshima","Tosu","Oita"]
#Extract only J1 and create a new data frame
game_J1_tmp = game_result[game_result["Tournament"] == "J1"]
Since it has not started yet, there is no data in "Score / Number of visitors / home_g / away_g / Results". It has nothing to do with this table, so you can ignore it.
fixturetable.py
#Create empty data frame to join
game_J1 = pd.DataFrame(index=team, columns=team)
for i, t in enumerate(team):
# [1]Extract each opponent, section and result for each team
team_tmp = game_J1_tmp.loc[game_J1_tmp["home"] == t, ["Away", "sec", "result"]]
# [2]Reset the index of the acquired data
team_tmp.reset_index(inplace=True, drop=True)
# [3]Sec for the team of extraction conditions:Add at 99
team_tmp.loc[17,:] = [t, 99, -1]
# [4]Add team order data from north
team_tmp["order"] = team_tmp["Away"].apply(lambda x: team.index(x) if x in team else -1)
# [5]Sort from north to team
team_tmp = team_tmp.sort_values("order")
# [6]Expand to the row of the final data frame (team of extraction conditions).
for x in range(len(team_tmp)):
game_J1.iloc[i, x] = team_tmp.at[team_tmp.index[x],"sec"]
Extract each opponent, section and result for each team
2 Reset the index of the acquired data
3 Add the team of extraction conditions with sec: 99
4 Add team order data from north
5 Sort from north to team 6 Expand to the row (team of extraction conditions) of the final data frame.
This is the final form of the data. Draw this on the graph.
fixturetable.py
plt.rcParams["font.family"] = "IPAexGothic"
fig = plt.figure(figsize=(6,6),dpi=144)
ax1 = fig.add_subplot(111)
teams = np.arange(len(team)+1)
h, v = 0.5, 0.5
ax1.set_ylim(18, 0)
ax1.set_xticks(teams)
ax1.set_yticks(teams)
ax1.xaxis.tick_top()
ax1.set_xticklabels(team, rotation=90)
ax1.set_yticklabels(team)
ax1.grid(True)
ax1.tick_params(axis="both", which="both", length=0)
#Display of the event section and coloring of squares without competition
for k, t in enumerate(team):
for i in range(18):
if game_J1.at[game_J1.index[i], t] == 99:
_ = patches.Rectangle(xy=(k, i), width=1.0, height=1.0, color="0.8")
ax1.add_patch(_)
else:
ax1.text(k+h, i+v, game_J1.at[game_J1.index[i], t], size=12, color = "k", ha="center", va="center")
ax1.set_title("2020 Meiji Yasuda Life J1 league record table", fontsize=16)
txt = "Source: JLeague Data Site"
fig.text(.9, .1, txt, fontsize=10, horizontalalignment="right")
txt3 = str(update) + "update"
fig.text(.9, .95, txt3, fontsize=10, horizontalalignment="right")
#fig.tight_layout()
plt.savefig("../img/J1fixturetable_noemblem_2020.png ", bbox_inches="tight")
The point of creating a graph is simple