mplsoccer.py_pizza module
A Python module for plotting pizza-plots.
Author: Anmol_Durgapal(@slothfulwave612)
The idea is inspired by Tom Worville, Football Slices, Soma Zero FC and Soumyajit Bose.
- class mplsoccer.py_pizza.PyPizza(params, min_range=None, max_range=None, background_color='#F2F2F2', inner_circle_size=5.0, straight_line_limit=100.0, straight_line_color='#808080', straight_line_lw=2.0, straight_line_ls='-', last_circle_color='#000000', last_circle_lw=2.0, last_circle_ls='-', other_circle_color='#808080', other_circle_lw=2.0, other_circle_ls='--')[source]
Bases:
object
A class for plotting pizza charts in Matplotlib.
- Parameters:
params (sequence of str) – The name of parameters (e.g. ‘Key Passes’)
min_range, max_range (sequence of floats, default None) – Minimum and maximum range for each parameter
background_color (str, default “#F2F2F2”) – The background-color of the plot.
inner_circle_size (float, default 5.0) – Size of the inner circle.
straight_line_limit (float, default 100.0) – Limit till which straight line will go.
straight_line_color (str, default “#808080”) – Color for the straight-lines.
straight_line_lw (float, default 2.0) – Linewidth for the straight-lines.
straight_line_ls (str, default ‘-’) – Linestyle for the straight-lines.
last_circle_color (str, default “#000000”) – Color for the last circle.
last_circle_lw (float, default 2.0) – Linewidth for the last circle.
last_circle_ls (str, default ‘-’) – Linestyle for the last circle.
other_circle_color (str, default “#808080”) – Color for other circles.
other_circle_lw (float, default 2.0) – Linewidth for other circle.
other_circle_ls (str, default “–”) – Linestyle for other circle.
Methods
adjust_texts
(params_offset[, offset, ...])To adjust the value-texts.
To fetch list of axes.text for comparison-values.
To fetch list of axes.text for params.
To fetch list containing theta values (x-coordinate for each text).
To fetch list of axes.text for values.
make_pizza
(values[, compare_values, bottom, ...])To make the pizza plot.
- make_pizza(values, compare_values=None, bottom=0.0, figsize=(24, 16), ax=None, param_location=108, slice_colors=None, value_colors=None, compare_colors=None, value_bck_colors=None, compare_value_colors=None, compare_value_bck_colors=None, color_blank_space=None, blank_alpha=0.5, kwargs_slices=None, kwargs_compare=None, kwargs_params=None, kwargs_values=None, kwargs_compare_values=None)[source]
To make the pizza plot.
- Parameters:
values (sequence of floats/int) – Values for each parameter.
compare_values (sequence of floats/int, default None) – Comparison Values for each parameter.
bottom (float, default 0.0) – Start value for the bar.
figsize (tuple of floats, default (24, 16)) – The figure size in inches (width, height).
ax (matplotlib axis, default None) – matplotlib.axes.Axes. If None is specified the pitch is plotted on a new figure.
param_location (float, default 108) – Location where params will be added.
slice_colors (sequence of str, default None) – Color for individual slices.
value_colors (sequence of str, default None) – Color for the individual values-text.
compare_colors (sequence of str, default None) – Color for the individual comparison-slices.
value_bck_colors (sequence of str, default None) – Color for background text-box for individual value-text.
compare_value_colors (sequence of str, default None) – Color for the individual comparison-values-text.
compare_value_bck_colors (sequence of str, default None) – Color for background text-box for individual comparison-value-text.
color_blank_space (str/sequence of str, default None.) –
- To color the blank space area in the plot.
if “same” –> same color as main-slices if sequence of str –> colors from the defined sequence
blank_alpha (float, default 0.5) – Alpha value for blank-space-colors
**kwargs_slices (All keyword arguments are passed on to axes.Axes.bar for slices.)
**kwargs_compare (All keyword arguments are passed on to axes.Axes.bar) – for comparison-slices.
**kwargs_params (All keyword arguments are passed on to axes.Axes.text) – for adding parameters.
**kwargs_values (All keyword arguments are passed on to axes.Axes.text) – for adding values.
**kwargs_compare_values (All keyword arguments are passed on to axes.Axes.text) – for adding comparison-values.
- Returns:
If ax=None returns a matplotlib Figure and Axes.
Else the settings are applied on an existing axis and returns None.
- adjust_texts(params_offset, offset=0.0, adj_comp_values=False)[source]
To adjust the value-texts. (if they are overlapping)
- Parameters:
params_offset (sequence of bool) – Pass True for parameter whose value are to be adjusted.
offset (float, default 0.0) – The value will define how much adjustment will be made.
adj_comp_values (bool, defaults False) – To make adjustment for comparison-values-text.