Skip to main content

Volleyball

from sportypy.surfaces.volleyball import VolleyballCourt

VolleyballCourt​

A subclass of BaseSurfacePlot to make a generic volleyball court.

This allows for the creation of the volleyball court in a way that is entirely parameterized by the court's baseline characteristics.

All attributes should default to 0.0 (if of a numeric type) or an empty string (if of a string type). Customized parameters may be specified via a child class (see below) or by directly specifying all necessary attributes of a valid volleyball court. The attributes needed to instantiate a particular league's surface must be specified in the court_params dictionary. For many leagues, these will be provided in the surface_dimensions.json file in the data/ subdirectory of sportypy.

See the BaseSurfacePlot and BaseSurface class definitions for full details.

Attributes​

  • league_code (str): The league for which the plot should be drawn. This is case-insensitive but should be the shortened name of the league (e.g. "National Volleyball Association" should be either "NBA" or "nba"). The default is an empty string

  • rotation_amt (float): The angle (in degrees) through which to rotate the final plot. The default is 0.0

  • x_trans (float): The amount that the x coordinates are to be shifted. By convention, the +x axis extends from the center of the surface towards the right-hand basket when viewing the court in TV view. The default is 0.0

  • y_trans (float): The amount that the y coordinates are to be shifted. By convention, the +y axis extends from the center of the surface towards the top of the court when viewing the court in TV view. The default is 0.0

  • feature_colors (dict): A dictionary of coloring parameters to pass to the plot

  • court_params (dict): A dictionary containing the following parameters of the court:

    • court_length (float): The length of the court
    • court_width (float): The width of the court
    • free_zone_end_line (float): The distance beyond the end line that the free zone extends. This is measured from the exterior edge of the end line
    • free_zone_sideline (float): The distance beyond the sideline that the free zone extends. This is measured from the exterior edge of the sideline
    • court_apron_endline (float): The thickness of the court's apron beyond the end line
    • court_apron_sideline (float): The thickness of the court's apron beyond the sideline
    • line_thickness (float): The thickness of the lines of the court in the court's specified units
    • attack_line_edge_to_center_line (float): The distance from the edge of the attack line to the center line, measuring from the outer (end line side) edge of the attack line to the center of the center line (x = 0 in TV view)
    • substitution_zone_dash_length (float): The length of a substitution zone dash measured in the direction perpendicular to the sideline
    • substitution_zone_dash_breaks (float): The separation between dashes in the substitution zone
    • substitution_zone_rep_pattern (str): The number of times that the break-dash pattern should be repeated to generate the substitution zone
    • service_zone_mark_length (float): The length of the service zone marker when measured in the direction perpendicular to the end line
    • service_zone_mark_to_end_line (float): The separation between the outer edge of the end line and the inner edge of the service zone mark

Leagues​

Each class below is a VolleyballCourt with that league's rule-book dimensions.

Classleague_codeDescription
FIVBCourtfivbA subclass of VolleyballCourt specific to FIVB.
NCAACourtncaaA subclass of VolleyballCourt specific to NCAA.
USAVolleyballCourtusa volleyballA subclass of VolleyballCourt specific to USA Volleyball.

Methods​

draw​

VolleyballCourt.draw(ax = None, display_range = 'full', xlim = None, ylim = None, rotation = None)

Draw the court.

Parameters​

  • ax (matplotlib.Axes): An Axes object onto which the plot can be drawn. If None is supplied, then the currently-active Axes object will be used

  • display_range (str): The portion of the surface to display. The entire surface will always be drawn under the hood, however this parameter limits what is shown in the final plot. The following explain what each display range corresponds to:

    • "full": The entire court
    • "in bounds only": The full in-bound area of the court
    • "in_bounds_only": The full in-bound area of the court
    • "offense": The attacking/offensive half court
    • "offence": The attacking/offensive half court
    • "offensivehalfcourt": The attacking/offensive half court
    • "offensive_half_court": The attacking/offensive half court
    • "offensive half court": The attacking/offensive half court
    • "defense": The defensive half court
    • "defence": The defensive half court
    • "defensivehalfcourt": The defensive half court
    • "defensive_half_court": The defensive half court
    • "defensive half court": The defensive half court

    The default is "full"

  • xlim (float or tuple of floats or None): The display range in the x direction to be used. If a single float is provided, this will be used as the lower bound of the x coordinates to display and the upper bound will be the +x end of the court. If a tuple, the two values will be used to determine the bounds. If None, then the display_range will be used instead to set the bounds. The default is None

  • ylim (float or tuple of floats or None): The display range in the y direction to be used. If a single float is provided, this will be used as the lower bound of the y coordinates to display and the upper bound will be the +y side of the court. If a tuple, the two values will be used to determine the bounds. If None, then the display_range will be used instead to set the bounds. The default is None

  • rotation (float or None): Angle (in degrees) through which to rotate the court when drawing. If used, this will set the class attribute of _rotation. A value of 0.0 will correspond to a TV view of the court, where +x is to the right and +y is on top. The rotation occurs counterclockwise. The default is None

cani_plot_leagues​

VolleyballCourt.cani_plot_leagues(league_code = None)

Show if a league can be plotted, or what leagues are pre-defined.

A user may wish to know if a specific volleyball league can be plotted. This method allows a user to check if that specific league code comes shipped with sportypy for easier plotting (if they provide the league code), or can also show what leagues are available to be plotted

Parameters​

  • league_code (str or None): A league code that may or may not be shipped with the package. If the league code is None, this will display all leagues that do come shipped with sportypy. The default is None

Returns​

  • Nothing, but a message will be printed out:

cani_color_features​

VolleyballCourt.cani_color_features()

Determine what features of the court can be colored.

This function is a helper function for the user to aid in plot styling and customization. The printed result of this method will be the names of the features that are able to be colored

Returns​

  • Nothing, but a message will be printed out:

cani_change_dimensions​

VolleyballCourt.cani_change_dimensions()

Determine what features of the court can be re-parameterized.

This function is a helper function for the user to aid in customizing a court's parameters. The printed result of this method will be the names of the features that are able to be reparameterized. This method is also useful when defining new features and using an existing league's court dimensions as a starting point

Returns​

  • Nothing, but a message will be printed out:

update_colors​

VolleyballCourt.update_colors(color_updates = {}, *args, **kwargs)

Update the colors currently used in the plot.

The colors can be passed at the initial instantiation of the class via the color_updates parameter, but this method allows the colors to be updated after the initial instantiation and will re-instantiate the class with the new colors

Parameters​

  • color_updates (dict): A dictionary where the keys correspond to the name of the feature that's color is to be updated (see cani_color_features() method for a list of these names). The default is an empty dictionary

Returns​

  • Nothing, but the class is re-instantiated with the updated colors:

update_court_params​

VolleyballCourt.update_court_params(court_param_updates = {}, *args, **kwargs)

Update the court's defining parameters.

This method should primarily be used in cases when plotting a league not currently supported by sportypy

Parameters​

  • court_updates (dict): A dictionary where the keys correspond to the name of the parameter of the court that is to be updated (see cani_change_dimensions() method for a list of these parameters). The default is an empty dictionary

Returns​

  • Nothing, but the class is re-instantiated with the updated parameters:

reset_colors​

VolleyballCourt.reset_colors()

Reset the features of the court to their default color set.

The colors can be passed at the initial instantiation of the class via the color_updates parameter, and through the update_colors() method, these can be changed. This method allows the colors to be reset to their default values after experiencing such a change

reset_court_params​

VolleyballCourt.reset_court_params()

Reset the features of the court to their default parameterizations.

The court parameters can be passed at the initial instantiation of the class via the court_updates parameter, and through the update_court_params() method, these can be changed. This method allows the feature parameterization to be reset to their default values after experiencing such a change