skillcornerviz 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- skillcornerviz/__init__.py +0 -0
- skillcornerviz/resources/Roboto/Roboto-Black.ttf +0 -0
- skillcornerviz/resources/Roboto/Roboto-BlackItalic.ttf +0 -0
- skillcornerviz/resources/Roboto/Roboto-Bold.ttf +0 -0
- skillcornerviz/resources/Roboto/Roboto-BoldItalic.ttf +0 -0
- skillcornerviz/resources/Roboto/Roboto-Italic.ttf +0 -0
- skillcornerviz/resources/Roboto/Roboto-Light.ttf +0 -0
- skillcornerviz/resources/Roboto/Roboto-LightItalic.ttf +0 -0
- skillcornerviz/resources/Roboto/Roboto-Medium.ttf +0 -0
- skillcornerviz/resources/Roboto/Roboto-MediumItalic.ttf +0 -0
- skillcornerviz/resources/Roboto/Roboto-Regular.ttf +0 -0
- skillcornerviz/resources/Roboto/Roboto-Thin.ttf +0 -0
- skillcornerviz/resources/Roboto/Roboto-ThinItalic.ttf +0 -0
- skillcornerviz/resources/__init__.py +0 -0
- skillcornerviz/standard_plots/__init__.py +0 -0
- skillcornerviz/standard_plots/bar_plot.py +342 -0
- skillcornerviz/standard_plots/formating.py +92 -0
- skillcornerviz/standard_plots/radar_plot.py +341 -0
- skillcornerviz/standard_plots/scatter_plot.py +345 -0
- skillcornerviz/standard_plots/summary_table.py +522 -0
- skillcornerviz/standard_plots/swarm_violin_plot.py +284 -0
- skillcornerviz/utils/__init__.py +0 -0
- skillcornerviz/utils/constants.py +231 -0
- skillcornerviz/utils/skillcorner_colors.py +113 -0
- skillcornerviz/utils/skillcorner_game_intelligence_utils.py +349 -0
- skillcornerviz/utils/skillcorner_physical_utils.py +175 -0
- skillcornerviz/utils/skillcorner_utils.py +147 -0
- skillcornerviz-1.0.0.dist-info/LICENSE +17 -0
- skillcornerviz-1.0.0.dist-info/METADATA +49 -0
- skillcornerviz-1.0.0.dist-info/RECORD +32 -0
- skillcornerviz-1.0.0.dist-info/WHEEL +5 -0
- skillcornerviz-1.0.0.dist-info/top_level.txt +1 -0
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Liam Bailey
|
|
3
|
+
16/03/2023
|
|
4
|
+
Bar plot
|
|
5
|
+
The plot_bar_chart function is used to generate a bar chart based on the given data.
|
|
6
|
+
It accepts various parameters such as the DataFrame (df) containing the metric data,
|
|
7
|
+
the column to plot on the axis (x_value), labels for the axis (label) and the
|
|
8
|
+
unit of measurement (unit), groups of players to highlight (primary_highlight_group
|
|
9
|
+
and secondary_highlight_group), colors for highlighting (primary_highlight and
|
|
10
|
+
secondary_highlight_color), and other optional customization parameters.
|
|
11
|
+
"""
|
|
12
|
+
import matplotlib.pyplot as plt
|
|
13
|
+
|
|
14
|
+
from matplotlib.ticker import EngFormatter
|
|
15
|
+
import pandas as pd
|
|
16
|
+
from skillcornerviz.utils.constants import BASE_COLOR, PRIMARY_HIGHLIGHT_COLOR, SECONDARY_HIGHLIGHT_COLOR, \
|
|
17
|
+
DARK_PRIMARY_HIGHLIGHT_COLOR, DARK_SECONDARY_HIGHLIGHT_COLOR, DARK_BASE_COLOR
|
|
18
|
+
from skillcornerviz.utils.constants import TEXT_COLOR
|
|
19
|
+
from pkg_resources import resource_filename
|
|
20
|
+
from matplotlib import font_manager as fm
|
|
21
|
+
import matplotlib.patheffects as pe
|
|
22
|
+
|
|
23
|
+
fonts = ['resources/Roboto/Roboto-Black.ttf',
|
|
24
|
+
'resources/Roboto/Roboto-BlackItalic.ttf',
|
|
25
|
+
'resources/Roboto/Roboto-Bold.ttf',
|
|
26
|
+
'resources/Roboto/Roboto-BoldItalic.ttf',
|
|
27
|
+
'resources/Roboto/Roboto-Italic.ttf',
|
|
28
|
+
'resources/Roboto/Roboto-Light.ttf',
|
|
29
|
+
'resources/Roboto/Roboto-LightItalic.ttf',
|
|
30
|
+
'resources/Roboto/Roboto-Medium.ttf',
|
|
31
|
+
'resources/Roboto/Roboto-MediumItalic.ttf',
|
|
32
|
+
'resources/Roboto/Roboto-Regular.ttf',
|
|
33
|
+
'resources/Roboto/Roboto-Thin.ttf',
|
|
34
|
+
'resources/Roboto/Roboto-ThinItalic.ttf']
|
|
35
|
+
|
|
36
|
+
for f in fonts:
|
|
37
|
+
filepath = resource_filename('skillcornerviz', f)
|
|
38
|
+
fm.fontManager.addfont(filepath)
|
|
39
|
+
plt.rcParams["font.family"] = "Roboto"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def plot_bar_chart(df,
|
|
43
|
+
metric,
|
|
44
|
+
label=None,
|
|
45
|
+
unit=None,
|
|
46
|
+
primary_highlight_group=None,
|
|
47
|
+
secondary_highlight_group=None,
|
|
48
|
+
primary_highlight_color=PRIMARY_HIGHLIGHT_COLOR,
|
|
49
|
+
secondary_highlight_color=SECONDARY_HIGHLIGHT_COLOR,
|
|
50
|
+
data_point_id='player_name',
|
|
51
|
+
data_point_label='player_name',
|
|
52
|
+
plot_title=None,
|
|
53
|
+
base_color=BASE_COLOR,
|
|
54
|
+
add_bar_values=False,
|
|
55
|
+
figsize=(8, 4),
|
|
56
|
+
lim=None,
|
|
57
|
+
order=None,
|
|
58
|
+
vertical=False,
|
|
59
|
+
rotation=90,
|
|
60
|
+
fontsize=7,
|
|
61
|
+
dark_mode=False):
|
|
62
|
+
"""
|
|
63
|
+
Plot a bar chart using the given data.
|
|
64
|
+
|
|
65
|
+
Parameters
|
|
66
|
+
----------
|
|
67
|
+
df : DataFrame
|
|
68
|
+
Metric DataFrame.
|
|
69
|
+
metric : str
|
|
70
|
+
The column in df we want to plot on the x-axis.
|
|
71
|
+
label : str, optional
|
|
72
|
+
The label for the x-axis. This should reflect what the x_value is.
|
|
73
|
+
unit : str, optional
|
|
74
|
+
If we want to add a unit to the axis values. For example % or km/h.
|
|
75
|
+
primary_highlight_group : list, optional
|
|
76
|
+
A group of players to label & highlight in Primary Color
|
|
77
|
+
secondary_highlight_group : list, optional
|
|
78
|
+
A group of players to label & highlight in Secondary Color.
|
|
79
|
+
primary_highlight_color : str, optional
|
|
80
|
+
The color for primary highlighted players (default: 'PHYSICAL PITCH').
|
|
81
|
+
secondary_highlight_color : str, optional
|
|
82
|
+
The color for secondary highlighted players (default: 'PHYSICAL PITCH S60' from SkillCorner's Palette).
|
|
83
|
+
data_point_id : str, optional
|
|
84
|
+
The identifier column for each data point (default: 'player_name').
|
|
85
|
+
data_point_label : str, optional
|
|
86
|
+
The label column for each data point (default: 'player_name').
|
|
87
|
+
plot_title : str, optional
|
|
88
|
+
The title of the plot.
|
|
89
|
+
base_color : str, optional
|
|
90
|
+
The base color for the bars (default: 'INNOVATION' from SkillCorner's Palette).
|
|
91
|
+
figsize : tuple, optional
|
|
92
|
+
Tuple (x, y) that defines the dimensions of the figure (default: (8, 4)).
|
|
93
|
+
lim: tuple, optional
|
|
94
|
+
Tuple (x, y) that defines the axis limits
|
|
95
|
+
order : list, optional
|
|
96
|
+
List that orders the axis (dimensional data) (default: None)
|
|
97
|
+
vertical: bool, optional
|
|
98
|
+
Orients the chart vertically or horizontally. (default: False)
|
|
99
|
+
rotation: int, optional
|
|
100
|
+
Rotates the labels if vertical=True is used. (default: 90)
|
|
101
|
+
fontsize: int, optional
|
|
102
|
+
Sets the fontsize used for texts.
|
|
103
|
+
|
|
104
|
+
Returns
|
|
105
|
+
-------
|
|
106
|
+
fig : matplotlib.figure.Figure
|
|
107
|
+
The generated figure.
|
|
108
|
+
ax : matplotlib.axes.Axes
|
|
109
|
+
The generated axes.
|
|
110
|
+
|
|
111
|
+
"""
|
|
112
|
+
# Error Handling
|
|
113
|
+
|
|
114
|
+
if metric not in df.columns:
|
|
115
|
+
raise ValueError("The metric you have entered is not in the DataFrame")
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
if dark_mode:
|
|
119
|
+
background_color = TEXT_COLOR
|
|
120
|
+
primary_highlight_color = DARK_PRIMARY_HIGHLIGHT_COLOR
|
|
121
|
+
secondary_highlight_color = DARK_SECONDARY_HIGHLIGHT_COLOR
|
|
122
|
+
text_color = 'white'
|
|
123
|
+
edge_color = None
|
|
124
|
+
else:
|
|
125
|
+
background_color = 'white'
|
|
126
|
+
text_color = TEXT_COLOR
|
|
127
|
+
edge_color = None
|
|
128
|
+
|
|
129
|
+
if label is None:
|
|
130
|
+
label = unit
|
|
131
|
+
|
|
132
|
+
# Setting the font to our SkillCorner font.
|
|
133
|
+
if primary_highlight_group is None:
|
|
134
|
+
primary_highlight_group = []
|
|
135
|
+
if secondary_highlight_group is None:
|
|
136
|
+
secondary_highlight_group = []
|
|
137
|
+
|
|
138
|
+
# Setting plot size & background.
|
|
139
|
+
fig, ax = plt.subplots(figsize=figsize)
|
|
140
|
+
fig.patch.set_facecolor(background_color)
|
|
141
|
+
ax.set_facecolor(background_color)
|
|
142
|
+
|
|
143
|
+
# Sorting the dataframe based on the metric to plot.
|
|
144
|
+
if order is None:
|
|
145
|
+
if not vertical:
|
|
146
|
+
df = df.sort_values(by=metric)
|
|
147
|
+
else:
|
|
148
|
+
df = df.sort_values(by=metric, ascending=False)
|
|
149
|
+
else:
|
|
150
|
+
df[data_point_id] = pd.Categorical(df[data_point_id], categories=order, ordered=True)
|
|
151
|
+
df = df.sort_values(data_point_id)
|
|
152
|
+
y_pos = range(0, len(df))
|
|
153
|
+
|
|
154
|
+
# Plotting bars.
|
|
155
|
+
if not vertical:
|
|
156
|
+
bars = ax.barh(y_pos,
|
|
157
|
+
df[metric],
|
|
158
|
+
color=DARK_BASE_COLOR if dark_mode else BASE_COLOR,
|
|
159
|
+
edgecolor=edge_color,
|
|
160
|
+
lw=0.5,
|
|
161
|
+
zorder=3,
|
|
162
|
+
alpha=1
|
|
163
|
+
# alpha=0.1 if dark_mode is True, else alpha=1
|
|
164
|
+
)
|
|
165
|
+
# Looping through data & bars to highlight specific players.
|
|
166
|
+
for i, bar in zip(y_pos, bars):
|
|
167
|
+
# If the player has been included in the comparison_players or target_players
|
|
168
|
+
if df[data_point_id].iloc[i] in secondary_highlight_group or \
|
|
169
|
+
df[data_point_id].iloc[i] in primary_highlight_group:
|
|
170
|
+
bar.set_color(secondary_highlight_color)
|
|
171
|
+
bar.set_alpha(1)
|
|
172
|
+
|
|
173
|
+
# If the player has been included in the target_players
|
|
174
|
+
if df[data_point_id].iloc[i] in primary_highlight_group:
|
|
175
|
+
bar.set_color(primary_highlight_color)
|
|
176
|
+
|
|
177
|
+
# Apply to all bars.
|
|
178
|
+
bar.set_edgecolor(edge_color)
|
|
179
|
+
bar.set_linewidth(0.5)
|
|
180
|
+
|
|
181
|
+
if add_bar_values:
|
|
182
|
+
if unit is not None:
|
|
183
|
+
# If a unit has been given, a string with the rounded value is created, including the unit
|
|
184
|
+
str_value = str(round(df[metric].iloc[i], 2)) + ' ' + unit + ' '
|
|
185
|
+
else:
|
|
186
|
+
# If a unit is not given, only the rounded string is created
|
|
187
|
+
str_value = str(round(df[metric].iloc[i], 2)) + ' '
|
|
188
|
+
|
|
189
|
+
# Adding the str_value to the plot
|
|
190
|
+
ax.text(df[metric].iloc[i], i, str_value,
|
|
191
|
+
# Stylistic features for the plot
|
|
192
|
+
ha='right', va='center',
|
|
193
|
+
fontsize=fontsize, fontweight='bold',
|
|
194
|
+
color=background_color if dark_mode else 'white',
|
|
195
|
+
path_effects=[pe.withStroke(linewidth=.75,
|
|
196
|
+
foreground=text_color,
|
|
197
|
+
alpha=1)])
|
|
198
|
+
else:
|
|
199
|
+
if add_bar_values:
|
|
200
|
+
if unit is not None:
|
|
201
|
+
# If a unit has been given, a string with the rounded value is created, including the unit
|
|
202
|
+
str_value = str(round(df[metric].iloc[i], 2)) + ' ' + unit + ' '
|
|
203
|
+
else:
|
|
204
|
+
# If a unit is not given, only the rounded string is created
|
|
205
|
+
str_value = str(round(df[metric].iloc[i], 2)) + ' '
|
|
206
|
+
|
|
207
|
+
# Adding the str_value to the plot
|
|
208
|
+
ax.text(df[metric].iloc[i], i, str_value,
|
|
209
|
+
# Stylistic features for the plot
|
|
210
|
+
ha='right', va='center',
|
|
211
|
+
fontsize=fontsize, fontweight='bold',
|
|
212
|
+
color=text_color,
|
|
213
|
+
path_effects=[pe.withStroke(linewidth=.75,
|
|
214
|
+
foreground=background_color if dark_mode else 'white',
|
|
215
|
+
alpha=1)])
|
|
216
|
+
|
|
217
|
+
# Setting plot elements to #0C1B37.
|
|
218
|
+
ax.spines['left'].set_color(text_color)
|
|
219
|
+
ax.spines['bottom'].set_color(None)
|
|
220
|
+
# Setting y ticks to player names.
|
|
221
|
+
ax.set_yticks(y_pos)
|
|
222
|
+
ax.set_yticklabels(df[data_point_label])
|
|
223
|
+
|
|
224
|
+
# Setting player names for those in comparison or target groups to bold.
|
|
225
|
+
for i, tick_label in enumerate(ax.get_yticklabels()):
|
|
226
|
+
if df[data_point_id].iloc[i] in secondary_highlight_group or \
|
|
227
|
+
df[data_point_id].iloc[i] in primary_highlight_group:
|
|
228
|
+
tick_label.set_fontproperties({'weight': 'bold', 'size': fontsize})
|
|
229
|
+
else:
|
|
230
|
+
tick_label.set_fontproperties({'size': fontsize})
|
|
231
|
+
|
|
232
|
+
# If a unit has been specified, apply it to the x-axis.
|
|
233
|
+
if unit is not None:
|
|
234
|
+
formatter0 = EngFormatter(unit=unit)
|
|
235
|
+
ax.xaxis.set_major_formatter(formatter0)
|
|
236
|
+
# Setting x label.
|
|
237
|
+
ax.set_xlabel(label,
|
|
238
|
+
fontweight='bold',
|
|
239
|
+
fontsize=fontsize,
|
|
240
|
+
labelpad=8)
|
|
241
|
+
# If you give a lim we set it
|
|
242
|
+
if lim is not None:
|
|
243
|
+
ax.set_xlim(lim)
|
|
244
|
+
|
|
245
|
+
elif vertical:
|
|
246
|
+
bars = ax.bar(y_pos,
|
|
247
|
+
df[metric],
|
|
248
|
+
color=base_color,
|
|
249
|
+
edgecolor=text_color,
|
|
250
|
+
lw=0.5,
|
|
251
|
+
zorder=3,
|
|
252
|
+
alpha=1)
|
|
253
|
+
# Looping through data & bars to highlight specific players.
|
|
254
|
+
for i, bar in zip(y_pos, bars):
|
|
255
|
+
# If the player has been included in the comparison_players or target_players
|
|
256
|
+
if df[data_point_id].iloc[i] in secondary_highlight_group or \
|
|
257
|
+
df[data_point_id].iloc[i] in primary_highlight_group:
|
|
258
|
+
bar.set_color(secondary_highlight_color)
|
|
259
|
+
|
|
260
|
+
# If the player has been included in the target_players
|
|
261
|
+
if df[data_point_id].iloc[i] in primary_highlight_group:
|
|
262
|
+
bar.set_color(primary_highlight_color)
|
|
263
|
+
|
|
264
|
+
# Apply to all bars.
|
|
265
|
+
bar.set_edgecolor(text_color)
|
|
266
|
+
bar.set_linewidth(0.5)
|
|
267
|
+
|
|
268
|
+
if add_bar_values:
|
|
269
|
+
if unit is not None:
|
|
270
|
+
str_value = str(round(df[metric].iloc[i], 2)) + ' ' + unit
|
|
271
|
+
else:
|
|
272
|
+
str_value = str(round(df[metric].iloc[i], 2))
|
|
273
|
+
|
|
274
|
+
ax.text(i, df[metric].iloc[i], str_value,
|
|
275
|
+
ha='center', va='bottom',
|
|
276
|
+
fontsize=fontsize, fontweight='bold',
|
|
277
|
+
color=text_color,
|
|
278
|
+
path_effects=[pe.withStroke(linewidth=.75,
|
|
279
|
+
foreground='white',
|
|
280
|
+
alpha=1)])
|
|
281
|
+
|
|
282
|
+
# Setting plot elements to #0C1B37.
|
|
283
|
+
ax.spines['left'].set_color(None)
|
|
284
|
+
ax.spines['bottom'].set_color(text_color)
|
|
285
|
+
|
|
286
|
+
# Setting y ticks to player names.
|
|
287
|
+
ax.set_xticks(y_pos)
|
|
288
|
+
ax.set_xticklabels(df[data_point_label], rotation=rotation)
|
|
289
|
+
|
|
290
|
+
# Setting player names for those in comparison or target groups to bold.
|
|
291
|
+
for i, tick_label in enumerate(ax.get_xticklabels()):
|
|
292
|
+
if df[data_point_id].iloc[i] in secondary_highlight_group or \
|
|
293
|
+
df[data_point_id].iloc[i] in primary_highlight_group:
|
|
294
|
+
tick_label.set_fontproperties({'weight': 'bold', 'size': fontsize})
|
|
295
|
+
else:
|
|
296
|
+
tick_label.set_fontproperties({'size': fontsize})
|
|
297
|
+
|
|
298
|
+
# If a unit has been specified, apply it to the x-axis.
|
|
299
|
+
if unit is not None:
|
|
300
|
+
formatter0 = EngFormatter(unit=unit)
|
|
301
|
+
ax.yaxis.set_major_formatter(formatter0)
|
|
302
|
+
# Setting x label.
|
|
303
|
+
ax.set_ylabel(label,
|
|
304
|
+
fontweight='bold',
|
|
305
|
+
fontsize=fontsize)
|
|
306
|
+
# If you give a lim we set it
|
|
307
|
+
if lim is not None:
|
|
308
|
+
ax.set_ylim(lim)
|
|
309
|
+
|
|
310
|
+
# Hiding the top & right spines.
|
|
311
|
+
ax.spines['top'].set_color('none')
|
|
312
|
+
ax.spines['right'].set_color('none')
|
|
313
|
+
|
|
314
|
+
# Setting axis label style params.
|
|
315
|
+
ax.tick_params(axis='x',
|
|
316
|
+
colors=text_color,
|
|
317
|
+
labelsize=fontsize,
|
|
318
|
+
length=0)
|
|
319
|
+
ax.tick_params(axis='y',
|
|
320
|
+
colors=text_color,
|
|
321
|
+
labelsize=fontsize)
|
|
322
|
+
|
|
323
|
+
ax.yaxis.label.set_color(text_color)
|
|
324
|
+
ax.xaxis.label.set_color(text_color)
|
|
325
|
+
|
|
326
|
+
# Add grid.
|
|
327
|
+
ax.grid(color=text_color,
|
|
328
|
+
axis='both',
|
|
329
|
+
linestyle='--',
|
|
330
|
+
linewidth=0.5,
|
|
331
|
+
alpha=0.25,
|
|
332
|
+
zorder=1)
|
|
333
|
+
|
|
334
|
+
if plot_title is not None:
|
|
335
|
+
ax.set_title(plot_title, fontweight='normal', color=text_color)
|
|
336
|
+
|
|
337
|
+
for k, spine in ax.spines.items():
|
|
338
|
+
spine.set_zorder(10)
|
|
339
|
+
plt.tight_layout()
|
|
340
|
+
plt.show()
|
|
341
|
+
|
|
342
|
+
return fig, ax
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Michael Nanopoulos
|
|
3
|
+
Simple function that takes an ax, x , and y
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from matplotlib.ticker import EngFormatter
|
|
8
|
+
from skillcornerviz.utils.constants import TEXT_COLOR
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def standard_ax_formating(ax,
|
|
12
|
+
x_label,
|
|
13
|
+
y_label,
|
|
14
|
+
x_unit=None,
|
|
15
|
+
y_unit=None,
|
|
16
|
+
labelsize=7,
|
|
17
|
+
fontsize=7,
|
|
18
|
+
show_legend=True,
|
|
19
|
+
legend_fontsize=6,
|
|
20
|
+
show_left_spine=False,
|
|
21
|
+
dark_mode=False):
|
|
22
|
+
"""
|
|
23
|
+
Function to format the appearance of a matplotlib axis in a standardized way.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
ax (matplotlib.axis.Axis): The axis object to be formatted.
|
|
27
|
+
x_label (str): The label for the x-axis.
|
|
28
|
+
y_label (str): The label for the y-axis.
|
|
29
|
+
x_unit (str, optional): The unit for the values on the x-axis.
|
|
30
|
+
y_unit (str, optional): The unit for the values on the y-axis.
|
|
31
|
+
labelsize (int, optional): The font size of the axis labels.
|
|
32
|
+
fontsize (int, optional): The font size of the tick labels on the axes.
|
|
33
|
+
show_legend (bool, optional): Whether to show the legend on the plot.
|
|
34
|
+
legend_fontsize (int, optional): The font size of the legend labels.
|
|
35
|
+
show_left_spine (bool, optional): Whether to show the left spine of the plot.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
color = 'white' if dark_mode else TEXT_COLOR
|
|
39
|
+
# Set x-axis label properties
|
|
40
|
+
ax.set_xlabel(x_label, fontweight='bold', fontsize=labelsize, color=color)
|
|
41
|
+
# Set y-axis label properties
|
|
42
|
+
ax.set_ylabel(y_label, fontweight='bold', fontsize=labelsize, color=color)
|
|
43
|
+
|
|
44
|
+
# Set spine colors
|
|
45
|
+
ax.spines['bottom'].set_color(color)
|
|
46
|
+
ax.spines['top'].set_color('none')
|
|
47
|
+
ax.spines['right'].set_color('none')
|
|
48
|
+
ax.spines['left'].set_color('none')
|
|
49
|
+
if show_left_spine:
|
|
50
|
+
ax.spines['left'].set_color(color)
|
|
51
|
+
|
|
52
|
+
# Set tick parameters for x-axis and y-axis
|
|
53
|
+
ax.tick_params(axis='x', colors=color, labelsize=fontsize)
|
|
54
|
+
ax.tick_params(axis='y', colors=color, labelsize=fontsize, length=0)
|
|
55
|
+
|
|
56
|
+
# Add legend if show_legend is True
|
|
57
|
+
if show_legend:
|
|
58
|
+
ax.legend(facecolor=TEXT_COLOR if dark_mode else 'white',
|
|
59
|
+
edgecolor=TEXT_COLOR if dark_mode else 'white',
|
|
60
|
+
framealpha=0.6,
|
|
61
|
+
labelcolor=color,
|
|
62
|
+
fontsize=legend_fontsize,
|
|
63
|
+
loc='center left',
|
|
64
|
+
bbox_to_anchor=(1.01, 0.5))
|
|
65
|
+
|
|
66
|
+
# Format x-axis tick labels with the specified unit
|
|
67
|
+
if x_unit is not None:
|
|
68
|
+
formatter0 = EngFormatter(unit=x_unit)
|
|
69
|
+
ax.xaxis.set_major_formatter(formatter0)
|
|
70
|
+
|
|
71
|
+
# Format y-axis tick labels with the specified unit
|
|
72
|
+
if y_unit is not None:
|
|
73
|
+
formatter1 = EngFormatter(unit=y_unit)
|
|
74
|
+
ax.yaxis.set_major_formatter(formatter1)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def prep_label_for_radar(x):
|
|
78
|
+
label = x.lower().replace('count_', '').replace('_p90', '').replace(' P90', ''). \
|
|
79
|
+
replace('_per_30_tip', ' ').replace('runs', '').replace('opportunities_to_pass_to_', '').replace('_', ' '). \
|
|
80
|
+
strip().upper()
|
|
81
|
+
return label
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def simplify_label(x):
|
|
85
|
+
label = x.lower().replace('carrera a ', '').replace('carrera de ', '').replace('carrera para ', '').replace('carrera',
|
|
86
|
+
'').replace(' por ','\n'). \
|
|
87
|
+
replace('course pour ', '').replace('course de ', '').replace('course', ''). \
|
|
88
|
+
replace('être à la', '').replace('dans la ', '').replace('dans le ', ''). \
|
|
89
|
+
replace('corsa ', '').\
|
|
90
|
+
replace('runs', ''). \
|
|
91
|
+
strip().upper()
|
|
92
|
+
return label
|