Skip to main content

A Python package for processing and visualizing SkillCorner data with SkillCorner brand styling.

Project description

SkillCornerviz Overview

The SkillCornerviz Library is a Python package that provides functions to create standard visualizations frequently used by the SkillCorner data analysis team. It also includes functions to normalize SkillCorner data in various ways. This package is designed to streamline the data analysis process and facilitate the creation of insightful visualizations.


File Structure

skillcornerviz/
├── resources/
   ├── Roboto/   # Roboto font files (.ttf)
   └── Shentox/  # Shentox font files (.otf)
├── standard_plots/
   ├── __init__.py
   ├── bar_plot.py
   ├── formatting.py
   ├── narrative_ranking_plot.py
   ├── radar_plot.py
   ├── scatter_plot.py
   ├── summary_table.py
   ├── swarm_violin_plot.py
   ├── table_grid.py
   └── zscore_dotplot.py
├── utils/
   ├── __init__.py
   ├── _fonts.py
   ├── constants.py
   ├── skillcorner_colors.py
   ├── skillcorner_game_intelligence_utils.py
   ├── skillcorner_physical_utils.py
   └── skillcorner_utils.py
└── __init__.py

Installation Instructions

  • Open the Terminal
  • Ensure python is installed by running the command python --version through the terminal.
  • Ensure pip is installed by running the command pip --version through the terminal.
  • Once both python and pip are installed, you can install the package using pip install skillcornerviz.
  • Ensure that the package is installed using pip show skillcornerviz which will display information about the package if it has been installed.

Plot Examples - Including Code Snippets

Bar Plot

Code Snippet:

from skillcornerviz.standard_plots import bar_plot as bar
from skillcornerviz.utils import skillcorner_physical_utils as p_utils
from skillcorner.client import SkillcornerClient
import pandas as pd

client = SkillcornerClient(username='YOUR USERNAME', password='YOUR PASSWORD')
data = client.get_physical(params={'competition': 4, 'season': 28,
                                    'group_by': 'player,team,competition,season,group',
                                    'possession': 'all,tip,otip',
                                    'playing_time__gte': 60, 
                                    'count_match__gte':8,
                                    'data_version': '3'})

df = pd.DataFrame(data)
metrics = p_utils.add_standard_metrics(df)

df['plot_label'] = df['player_short_name'] + ' | ' + df['position_group']

fig, ax = bar.plot_bar_chart(df=df[(df['team_id'] == 262)], 
                             metric='psv99',
                             label='Peak Sprint Velocity 99th Percentile',
                             unit='km/h',
                             primary_highlight_group=[12253, 12251, 993, 31993],
                             add_bar_values=True,
                             data_point_id='player_id',
                             data_point_label='plot_label')

Bar Plot Figure:

Scatter Plot

Code Snippet:

from skillcornerviz.standard_plots import scatter_plot as scatter
from skillcornerviz.utils import skillcorner_physical_utils as p_utils
from skillcorner.client import SkillcornerClient
import pandas as pd


client = SkillcornerClient(username='YOUR USERNAME', password='YOUR PASSWORD')
data = client.get_physical(params={'competition': 4, 
                                   'season': 28,
                                   'group_by': 'player,team,competition,season,group',
                                   'possession': 'all,tip,otip', 
                                   'playing_time__gte': 60,
                                   'count_match__gte':8,
                                   'data_version': '3'})

df = pd.DataFrame(data)
metrics = p_utils.add_standard_metrics(df)

fig, ax = scatter.plot_scatter(df=df[df['position_group'].isin(['Midfield'])], 
                               x_metric='total_distance_per_90',
                               y_metric='hi_distance_per_90', 
                               data_point_id='team_name',
                               data_point_label='player_short_name',
                               x_label='Total Distance Per 90',
                               y_label="High Intensity Distance Per 90",
                               x_unit='m',
                               y_unit='m',
                               primary_highlight_group=['FC Barcelona'], 
                               secondary_highlight_group=['Real Madrid CF'])

Scatter Plot Figure

Radar Plot

Code Snippet

from skillcornerviz.standard_plots import radar_plot as radar
from skillcorner.client import SkillcornerClient
import pandas as pd

client = SkillcornerClient(username='YOUR_USERNAME', password='YOUR_PASSWORD')

# Request data for LaLiga 2023/2024.
data = client.get_in_possession_off_ball_runs(params={'competition': 4, 
                                                      'season': 28,
                                                      'playing_time__gte': 60,
                                                      'count_match__gte': 8,
                                                      'average_per': '30_min_tip',
                                                      'group_by': 'player,competition,team,group',
                                                      'run_type': 'all,run_in_behind,run_ahead_of_the_ball,'
                                                                 'support_run,pulling_wide_run,coming_short_run,'
                                                                 'underlap_run,overlap_run,dropping_off_run,'
                                                                 'pulling_half_space_run,cross_receiver_run'})

df = pd.DataFrame(data)

RUNS = {'count_cross_receiver_runs_per_30_min_tip': 'Cross Receiver',
        'count_runs_in_behind_per_30_min_tip': ' In Behind',
        'count_runs_ahead_of_the_ball_per_30_min_tip': 'Ahead Of The Ball',
        'count_overlap_runs_per_30_min_tip': 'Overlap',
        'count_underlap_runs_per_30_min_tip': 'Underlap',
        'count_support_runs_per_30_min_tip': 'Support',
        'count_coming_short_runs_per_30_min_tip': 'Coming Short',
        'count_dropping_off_runs_per_30_min_tip': 'Dropping Off',
        'count_pulling_half_space_runs_per_30_min_tip': 'Pulling Half-Space',
        'count_pulling_wide_runs_per_30_min_tip': 'Pulling Wide'}

# Plot off-ball run radar for Nico Williams.
fig, ax = radar.plot_radar(df=df[df['group'] == 'Wide Attacker'],
                            data_point_id='player_id',
                            label=35342,
                            plot_title='Off-Ball Run Profile | Nico Williams 2023/24',
                            metrics=RUNS.keys(), 
                            metric_labels=RUNS, 
                            percentiles_precalculated=False,
                            suffix=' Runs P30 TIP', 
                            positions='Wide Attackers',
                            matches=8,
                            minutes=60, 
                            competitions='LaLiga', 
                            seasons='2023/2024', 
                            add_sample_info=True)

Radar Plot Figure

Summary Table

Code Snippet

from skillcornerviz.standard_plots import summary_table as table
from skillcornerviz.utils import skillcorner_physical_utils as p_utils
from skillcorner.client import SkillcornerClient
import pandas as pd

client = SkillcornerClient(username='YOUR USERNAME', password='YOUR PASSWORD')
data = client.get_physical(params={'competition': 4, 
                                      'season': 28,
                                      'group_by': 'player,team,competition,season,group',
                                      'playing_time__gte': 60,
                                      'count_match__gte': 8,
                                      'possession': 'all,tip,otip',
                                      'data_version': '3'})

df = pd.DataFrame(data)
metrics = p_utils.add_standard_metrics(df)

plot_metrics = {'meters_per_minute_tip' : 'Meters Per Minute TIP',
        'meters_per_minute_otip' : 'Meters Per Minute OTIP',
        'highaccel_count_per_60_bip': 'Number Of High Accels Per 60 BIP',
        'highdecel_count_per_60_bip': 'Number Of High Decels Per 60 BIP',
        'sprint_count_per_60_bip': 'Number Sprints Per 60 BIP',
        'psv99' : 'Peak Sprint Velocity 99th Percentile'}

fig, ax = table.plot_summary_table(df=df[df['position_group'] == 'Midfield'], 
                                   metrics=list(plot_metrics.keys()), 
                                   metric_col_names=plot_metrics.values(), 
                                   percentiles_mode=True,
                                   data_point_id='player_name',
                                   data_point_label='player_short_name',
                                   highlight_group=[
                                            'Fermín López Marín',
                                            'Francis Coquelin',
                                            'Beñat Turrientes Imaz',
                                            'Sergi Darder Moll',
                                            'Toni Kroos',
                                            'Djibril Sow'])

Summary Table Figure

Swarm/Violin Plot

Code Snippet

from skillcornerviz.standard_plots import swarm_violin_plot as swarm_plot
from skillcornerviz.utils import skillcorner_game_intelligence_utils as gi_utils
from skillcorner.client import SkillcornerClient
import pandas as pd

client = SkillcornerClient(username='YOUR_USERNAME', password='YOUR_PASSWORD')

data = client.get_in_possession_off_ball_runs(params={'season': 28,
                                                      'competition': 4,
                                                      'group_by': 'player,team,competition,season,group',
                                                      'playing_time__gte': 60, 
                                                      'count_match__gte': 8})
df = pd.DataFrame(data)
metrics = gi_utils.add_run_normalisations(df)

midfielders = [4450, 9188, 25738, 118870, 24120, 13908]
forwards = [733366, 9106, 7619, 16381, 1401]

fig, ax = swarm_plot.plot_swarm_violin(df=df,
                                x_metric='runs_dangerous_percentage',
                                y_metric='group',
                                y_groups=['Center Forward', 'Midfield'],
                                x_label='Dangerous Run Percentage',
                                y_group_labels=['Center Forwards',
                                                'Midfielders'],
                                x_unit='%',
                                primary_highlight_group=midfielders,
                                secondary_highlight_group=forwards,
                                data_point_id='player_id',
                                data_point_label='short_name',
                                point_size=7)

Swarm Violin Plot Figure

Narrative Ranking Plot

Code Snippet

from skillcornerviz.standard_plots import narrative_ranking_plot as rank
from skillcorner.client import SkillcornerClient
import pandas as pd

client = SkillcornerClient(username='YOUR_USERNAME', password='YOUR_PASSWORD')

data = client.get_in_possession_off_ball_runs(params={'competition': 4,
                                                      'season': 28,
                                                      'group_by': 'player,team,competition,season,group',
                                                      'playing_time__gte': 60,
                                                      'count_match__gte': 8,
                                                      'average_per': '30_min_tip',
                                                      'run_type': 'all,run_in_behind,run_ahead_of_the_ball,'
                                                                 'support_run,pulling_wide_run,coming_short_run,'
                                                                 'underlap_run,overlap_run,dropping_off_run,'
                                                                 'pulling_half_space_run,cross_receiver_run'})
df = pd.DataFrame(data)

QUESTIONS = {
    'Off-Ball Runs': [
        'count_runs_in_behind_per_30_min_tip',
        'count_runs_ahead_of_the_ball_per_30_min_tip',
        'count_overlap_runs_per_30_min_tip',
        'count_underlap_runs_per_30_min_tip',
        'count_support_runs_per_30_min_tip',
        'count_coming_short_runs_per_30_min_tip',
    ]
}

wide_attackers = [35342, 9106, 7619]

fig, ax = rank.plot_ranking(
    df=df[df['group'] == 'Wide Attacker'],
    questions=QUESTIONS,
    highlight_group=wide_attackers,
    data_point_id='player_id',
    data_point_label='short_name',
    plot_title='Off-Ball Run Rankings | Wide Attackers LaLiga 2023/24',
)

Table Grid

Code Snippet

from skillcornerviz.standard_plots import table_grid as tgrid
from skillcornerviz.utils import skillcorner_physical_utils as p_utils
from skillcornerviz.utils import skillcorner_utils as skcu
from skillcorner.client import SkillcornerClient
import pandas as pd
from scipy import stats

client = SkillcornerClient(username='YOUR_USERNAME', password='YOUR_PASSWORD')

data = client.get_physical(params={'competition': 4,
                                   'season': 28,
                                   'group_by': 'player,team,competition,season,group',
                                   'possession': 'all,tip,otip',
                                   'playing_time__gte': 60,
                                   'count_match__gte': 8,
                                   'data_version': '3'})
df = pd.DataFrame(data)
p_utils.add_standard_metrics(df)

METRICS = ['total_distance_per_90', 'hi_distance_per_90', 'sprint_count_per_90', 'psv99']
LABELS  = ['Total Dist P90', 'HI Dist P90', 'Sprints P90', 'PSV99']

# Z-score each metric across the sample
for m in METRICS:
    df[f'{m}_z'] = stats.zscore(df[m])

midfielders = [4450, 9188, 25738, 118870, 24120, 13908]

fig, ax = tgrid.plot_table_grid(
    df=df[df['group'] == 'Midfield'],
    metrics=[f'{m}_z' for m in METRICS],
    labels=LABELS,
    data_point_id='player_id',
    highlight_group=midfielders,
    sort_by='total_distance_per_90_z',
    plot_title='Physical Profile | Midfielders LaLiga 2023/24',
)

Contact

If you encounter any issues, have suggestions, or would like to know more about the SkillCornerviz Library, please contact us at through this email: liam.bailey@skillcorner.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

skillcornerviz-1.2.1.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

skillcornerviz-1.2.1-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file skillcornerviz-1.2.1.tar.gz.

File metadata

  • Download URL: skillcornerviz-1.2.1.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for skillcornerviz-1.2.1.tar.gz
Algorithm Hash digest
SHA256 a65fa4aee6df91c1b3bcbc269eed72a82073d92dbeb9a94660ecde8c1e9185b9
MD5 6817ac8eaf6990d75e9e217914878b6a
BLAKE2b-256 500d2a95ca21cb24cd73c6baf90c6c6f0d8f065ee6c128c57e4e76cab73cfcc5

See more details on using hashes here.

File details

Details for the file skillcornerviz-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: skillcornerviz-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for skillcornerviz-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31d566cd03c6c48e44b4cc73dedc4ce06bd3c590a8e06bdd0df5291d49b8cccb
MD5 a371b87a21e82c8920fb7213a82eb6a5
BLAKE2b-256 93e518b2063232df56ff458d7a9269d73b3392cb6b68ae5e4970b436f171a285

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page