mplsoccer.bumpy_chart module
A Python module for plotting bump chart.
Author: Anmol_Durgapal(@slothfulwave612)
- class mplsoccer.bumpy_chart.Bumpy(background_color='#1B1B1B', scatter=True, scatter_color='#4F535C', line_color=None, scatter_points='o', scatter_primary=None, scatter_size=100, ticklabel_size=13, curviness=0.85, rotate_xticks=0, rotate_yticks=0, show_right=False, label_size=20, labelpad=20, alignment_xvalue=0.035, alignment_yvalue=0.16, label_color='#F2F2F2', plot_labels=True)[source]
Bases:
object
A class for plotting bump-charts in Matplotlib
- Parameters:
background_color (str, default “#1B1B1B”) – The background-color of the plot.
scatter (bool, default True) – To plot scatter points or not. “value” –> scatter point for highlighted attribute.
scatter_color (str, default “#4F535C”) – Color value for our scatter points.
line_color (str, default None) – Color value for the connecting lines. if None –> takes the same color as scatter_color.
scatter_points (str, default ‘o’) – Type of marker user wants to plot.
scatter_primary (str, default None) – Type of marker user wants to plot for highlighted attribute.
scatter_size (float, default 100) – Size of the scatter_points.
ticklabel_size (float, default 13) – Fontsize of the ticklabel.
curviness (float, default 0.85) – Value of the curved line.
rotate_xticks (float, default 0) – Rotation of xticklabels in degrees.
rotate_yticks (float, default 0) – Rotation of yticklabels.
show_right (bool, default False) – yticklabels to be shown at the right y-axis or not.
label_size (float, default 20) – Fontsize of the x and y labels.
labelpad (float, default 20) – Padding between labels and ticklables.
alignment_xvalue (float, default 0.035) – Value for alignment of x-label.
alignment_yvalue (float, default 0.16) – Value for alignment of y-label
label_color (str, default “#FFFFFF”) – Color value for labels.
plot_labels (bool, default True) – To plot the labels.
Methods
plot
(x_list, y_list, values, highlight_dict)Function to plot bumpy-chart.
- plot(x_list, y_list, values, highlight_dict, figsize=(12, 8), lw=2, secondary_alpha=1, x_label=None, y_label=None, xlim=None, ylim=None, ax=None, upside_down=False, **kwargs)[source]
Function to plot bumpy-chart.
- Parameters:
x_list (sequence of float/str) – xticklabel values(serial-wise order from left to right).
y_list (sequence of float/str) – yticklabel values(serial-wise order from top to bottom).
values (dict) – Containing key as team-name and value as list of rank for that team.
highlight_dict (dict) – Containing key as the team-name to be highlighted with their corresponding color.
figsize (tuple, default (12,8)) – Size of the plot. Defaults to (12,8).
lw (int, default 2) – Line-width for the lines in the plot.
secondary_alpha (float, default 1) – Alpha value for non-shaded lines/markers.
x_label, y_label (str, default None) – x-label and y-label name
xlim, ylim (tuple, default None) – Limit for x-axis and y-axis respectively.
ax (axes.Axes object, default None) – axes object on which chart will be plotted.
upside_down (bool, default False) – To plot chart upside down.
**kwargs (All other keyword arguments are passed for setting ticklabels and labels.)
- Returns:
If ax=None returns a matplotlib Figure and Axes.
Else the settings are applied on an existing axis and returns None.