Skip to main content

A Python library for creating interactive and customizable visualizations of basketball statistics.

Project description

🏀 basket-viz

A Python library for creating interactive and customizable visualizations of basketball statistics.

PyPI Version Python Version License Issues Last Commit Downloads

♻️ Install from PyPI

To install basket-viz, simply run:

pip install basket-viz

⛹️‍♂️Getting Started

🔍 Docs

For a comprehensive overview of features check out the documentation.

🎯 Shot Charts

from basket_viz.court.shot_charts import ShotChart

shot_chart = ShotChart()
shot_chart.plot_shot_chart(df, player_name="NEDOVIC, NEMANJA")

Alt Text

⬡ ⬢ Aggergated Shot Charts

df_all = shot_chart.get_all_entity_hexbin_data(df)

shot_chart.plot_entity_hexbin_sized(
    df_all,
    offsets_col='offsets',
    color_col='values_ratio',
    size_col='values_all',
    entity_name=player_name,
)

Alt Text

🔊 Radar Charts

The radar charts are the first kind that has layers. First layer being the chart, second being the image layer.

Standard Radar

radar_chart = RadarChart(
    dataframe=df_player_stats,
    columns=stats
)

radar_chart.plot_radar(player_name, title_sufix="\n Euroleague 2023/2024")   
radar_chart.add_player_image(img_path)
radar_chart.display_chart()

NOTE: The circular image is not mandatory.

Alt Text

Comparison Radar

radar_chart = RadarChart(
    dataframe=df_player_stats,
    columns=stats
)

player_names = ["Howard, Markus", "James, Mike"]
colors = [basconia_blue, monaco_gold]

# Plot the radar comparison
radar_chart.compare_radars(
    player_names=player_names,
    line_colors=colors,
    title="Euroleague 2023/2024 \n SCORRER COMPARISON"
)

# Add player images after plotting the radars
radar_chart.add_comparison_images(start_x=0.2, spacing=0.25, y_offset=-0.2)

# Display the chart
radar_chart.display_chart()

NOTE: The circular images are not mandatory.

Alt Text

🎢 Overlay

This module supports plotting static and animated overlay comparing the performance of individuals against the rest of the league.

from basket_viz.overlay.trajectory import PlotTrajectory

pt = PlotTrajectory()

players = ["Hezonja, Mario","James, Mike","Lessort, Mathias"]
colors = [real_madrid_gold, monaco_red, panathenaicos_green]
v_lines = {1.0: 'Short-Range', 4.0: 'Mid-Range', 6.75: 'Three-Point Line'}

pt.plot_trajectory_animated(normalized_df, players, colors, v_lines=v_lines, title=f"Scoring Profiles \n EUROLEAGUE 23/24")

Alt Text

🔴🟡🟢 Stat Grid

This module supports plotting stat heatmaps for all players per game.

It also comes with marking capability, to "zoom in" on particular players by highlighting them.

The shape of the values can be square or circle.

from basket_viz.stat_grid.season_stats import PlayerStatsHeatmap

ps = PlayerStatsHeatmap()


ps.set_params( highlight_params={
                "backgroundcolor": basconia_red,
                "fontweight": "bold",
                "edgecolor": basconia_blue,
                "lw": 3,
            })
ps.plot_stat_heatmap(df_stats, team='BAS', player_bames=['moneke, chima'.upper()], num_games=15, stat=stat)

Alt Text

📈 Relationships

This module supports plotting relationships between different stats of players int the team.

To apply collor template that matches the brand of Euroleague teams use use_team_config=True.

from basket_viz.relationships.plotter import PlotRelationship

plotter = PlotRelationship(use_team_config=True,output_format='mp4')
plotter.plot_animated_relationship(
    df,
    team_filter="BAR",
    display_only_last_names=True,
)

Alt Text

🙌 Contibuting

We are continuously working on improving this project and we welcome your contributions!

🐞 Open Issues

If you have any feature requests or bug reports, please don't hesitate to open an issue. This project is a work in progress, and your feedback is invaluable to us.

👨‍💻 Pick up Issues

You can also pick up an issue at any time and start working on it. Please make sure to follow our contribution guidelines to ensure a smooth collaboration process. Thank you for your support and happy coding!

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

basket_viz-0.2.1.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

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

basket_viz-0.2.1-py3-none-any.whl (34.0 kB view details)

Uploaded Python 3

File details

Details for the file basket_viz-0.2.1.tar.gz.

File metadata

  • Download URL: basket_viz-0.2.1.tar.gz
  • Upload date:
  • Size: 31.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.7

File hashes

Hashes for basket_viz-0.2.1.tar.gz
Algorithm Hash digest
SHA256 70865c594cbcf102c374380051e29d158df5ed9eb1b9fa2decb4205f3edf3832
MD5 e025ffe41f82f7b99e7c7a37bdf31900
BLAKE2b-256 e997d340ba1f141e09f82e811e790b492dc1f098d2556da4ebc7c675c6b7be7a

See more details on using hashes here.

File details

Details for the file basket_viz-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: basket_viz-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 34.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.7

File hashes

Hashes for basket_viz-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa90f444016381507ecf2a3029d8dddcb0f5ce63121b38a582a144597fe8a5d3
MD5 f7af4b0729e11176a03cedce5f5a4f01
BLAKE2b-256 2bbdc1b8a25ed78886357f7962488601f28f72c927d02f2cc57bee57c36df1d6

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