# Different Units # --------------- # Till now we were plotting a percentile chart where the upper limit was 100. # Let's take another example where the lower limit is 0 and upper limit is 5. # The below code shows how to plot pizza-chart for such case. # parameter and value list params = ['Speed', 'Agility', 'Strength', 'Passing', 'Dribbles'] values = [5, 2, 4, 3, 1] # instantiate PyPizza class baker = PyPizza( params=params, # list of parameters straight_line_color="#F2F2F2", # color for straight lines straight_line_lw=1, # linewidth for straight lines straight_line_limit=5.0, # max limit of straight lines last_circle_lw=0, # linewidth of last circle other_circle_lw=0, # linewidth for other circles inner_circle_size=0.4, # size of inner circle ) # plot pizza fig, ax = baker.make_pizza( values, # list of values figsize=(8, 8), # adjust figsize according to your need color_blank_space="same", # use same color to fill blank space blank_alpha=0.4, # alpha for blank-space colors param_location=5.5, # where the parameters will be added kwargs_slices=dict( facecolor="cornflowerblue", edgecolor="#F2F2F2", zorder=2, linewidth=1
"Passing %", "Deep Progression", "xG Assisted", "xG Buildup", "Successful Dribbles", "Fouls Won", "Turnovers", "Pressure Regains", "pAdj Tackles", "pAdj Interceptions" ] values = [82, 9.94, 0.22, 1.58, 1.74, 1.97, 2.43, 2.81, 3.04, 0.92] # Putellas values_2 = [76, 4.56, 0.09, 0.46, 1.08, 1.28, 1.84, 3.16, 2.66, 1.51] # League Average # minimum range value and maximum range value for parameters min_range = [74, 3.3, 0.03, 0.28, 0.4, 0.7, 2.6, 2.4, 1.1, 0.7] max_range = [90, 9.7, 0.20, 0.89, 2.1, 2.7, 0.4, 5.1, 3.7, 2.5] # instantiate PyPizza class baker = PyPizza( params=params, min_range=min_range, # min range values max_range=max_range, # max range values background_color="#222222", straight_line_color="#000000", last_circle_color="#000000", last_circle_lw=2.5, other_circle_lw=0, other_circle_color="#000000", straight_line_lw=1 ) # plot pizza fig, ax = baker.make_pizza( values, # list of values compare_values=values_2, # passing comparison values figsize=(8, 8), # adjust figsize according to your need color_blank_space="same", # use same color to fill blank space blank_alpha=0.4, # alpha for blank-space colors param_location=110, # where the parameters will be added kwargs_slices=dict( facecolor="#1A78CF", edgecolor="#000000", zorder=1, linewidth=1
] # value list # The values are taken from the excellent fbref website (supplied by StatsBomb) values = [70, 77, 74, 68, 60, 96, 89, 97, 92, 94, 16, 19, 56, 53, 94] # color for the slices and text slice_colors = ["#1A78CF"] * 5 + ["#FF9300"] * 5 + ["#D70232"] * 5 text_colors = ["#000000"] * 10 + ["#F2F2F2"] * 5 # instantiate PyPizza class baker = PyPizza( params=params, # list of parameters background_color="#EBEBE9", # background color straight_line_color="#EBEBE9", # color for straight lines straight_line_lw=1, # linewidth for straight lines last_circle_lw=0, # linewidth of last circle other_circle_lw=0, # linewidth for other circles inner_circle_size=20 # size of inner circle ) # plot pizza fig, ax = baker.make_pizza( values, # list of values figsize=(8, 8.5), # adjust figsize according to your need color_blank_space="same", # use same color to fill blank space slice_colors=slice_colors, # color for individual slices value_colors=text_colors, # color for the value-text value_bck_colors=slice_colors, # color for the blank spaces blank_alpha=0.4, # alpha for blank-space colors kwargs_slices=dict(edgecolor="#F2F2F2", zorder=2,
"Non-Penalty Goals", "npxG", "npxG per Shot", "xA", "Open Play\nShot Creating Actions", "\nPenalty Area\nEntries", "Progressive Passes", "Progressive Carries", "Successful Dribbles", "\nTouches\nper Turnover", "pAdj\nPress Regains", "Aerials Won" ] values = [99, 99, 87, 51, 62, 58, 45, 40, 27, 74, 77, 73] # for Robert Lewandowski values_2 = [83, 75, 55, 62, 72, 92, 92, 79, 64, 92, 68, 31] # for Mohamed Salah # instantiate PyPizza class baker = PyPizza( params=params, # list of parameters background_color="#EBEBE9", # background color straight_line_color="#222222", # color for straight lines straight_line_lw=1, # linewidth for straight lines last_circle_lw=1, # linewidth of last circle last_circle_color="#222222", # color of last circle other_circle_ls="-.", # linestyle for other circles other_circle_lw=1 # linewidth for other circles ) # plot pizza fig, ax = baker.make_pizza( values, # list of values compare_values=values_2, # comparison values figsize=(8, 8), # adjust figsize according to your need kwargs_slices=dict(facecolor="#1A78CF", edgecolor="#222222", zorder=2, linewidth=1), # values to be used when plotting slices kwargs_compare=dict(