Skip to content

Commit 941b14e

Browse files
Merge pull request #62 from UnravelSports/feat/player-ids
no ball label
2 parents 40f47aa + b6ab93c commit 941b14e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

unravel/soccer/graphs/graph_converter.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ def plot(
676676
anonymous: bool = False,
677677
plot_type: Literal["pitch_only", "graph_only", "full"] = "full",
678678
show_label: bool = True,
679+
show_ball_label: bool = False,
679680
show_timestamp: bool = True,
680681
next_closest_timestamp: bool = False,
681682
):
@@ -790,7 +791,8 @@ def plot(
790791
self._ball_color = ball_color
791792
self._color_by = color_by
792793
self._plot_type = plot_type
793-
self._show_pitch_label = show_label
794+
self._show_label = show_label
795+
self._show_ball_label = show_ball_label
794796
self._show_pitch_timestamp = show_timestamp
795797
self._next_closest_timestamp = next_closest_timestamp
796798

@@ -1110,10 +1112,14 @@ def player_and_ball(frame_data, ax):
11101112
(
11111113
self.get_player_by_id(r[Column.OBJECT_ID])["jersey_no"]
11121114
if r[Column.OBJECT_ID] != Constant.BALL
1113-
else Constant.BALL
1115+
else Constant.BALL if self._show_ball_label else ""
11141116
)
11151117
if not anonymous
1116-
else str(i)
1118+
else (
1119+
str(i)
1120+
if r[Column.OBJECT_ID] != Constant.BALL
1121+
else Constant.BALL if self._show_ball_label else ""
1122+
)
11171123
),
11181124
color=self._ball_color if is_ball else color,
11191125
fontsize=12,
@@ -1132,7 +1138,7 @@ def player_and_ball(frame_data, ax):
11321138
)
11331139

11341140
# Add label and timestamp to pitch if enabled
1135-
if self._show_pitch_label:
1141+
if self._show_label:
11361142
ax.set_xlabel(f"Label: {frame_data['label'][0]}", fontsize=22)
11371143
if self._show_pitch_timestamp:
11381144
ax.set_title(self._gameclock, fontsize=22)

0 commit comments

Comments
 (0)