BarChartRace

class pandas_alive.charts.BarChartRace(df: pandas.core.frame.DataFrame, interpolate_period: bool, steps_per_period: int, period_length: int, period_fmt: str, figsize: Tuple[float, float], title: str, fig: matplotlib.figure.Figure, cmap: Union[str, matplotlib.colors.Colormap, List[str]], tick_label_size: Union[int, float, str], period_label: Union[bool, Dict[str, Union[int, float, str]]], period_summary_func: Callable, fixed_max: bool, dpi: int, writer: str, enable_progress_bar: bool, kwargs, orientation: str, sort: str, label_bars: bool, bar_label_size: Union[int, float], n_visible: int, fixed_order: Union[list, bool], perpendicular_bar_func: Callable)[source]

BarChart implementation for bar chart races

Parameters

BaseChart (BaseChart) – Base class shared by all chart types

Returns

Instance of BarChart allowing for inclusion in subplot charts or animating with .save()

Return type

BarChart

Methods

BarChartRace.__init__(df, …)

Initialize self.

BarChartRace.anim_func(i)

Animation function, removes all bars and updates legend/period annotation.

BarChartRace.apply_style(ax)

Apply styling to axes with spines and grid, can be overridden

BarChartRace.calculate_new_figsize(real_fig)

Calculate figure size to allow for labels, etc

BarChartRace.calculate_ranks(df)

Calculate expanded dataframe to match length of animation

BarChartRace.clearing()

Function to remove all existing lines, collections, etc at the start of the animation AND after a save.

BarChartRace.create_figure()

Create Bar chart figure

BarChartRace.get_colors(cmap)

Get array of colours from BaseChart.get_colors and shorten to number of bars

BarChartRace.get_data_cols(df)

Get list of columns containing plottable numeric data to plot

BarChartRace.get_frames()

Method for determining range of frames to animate.

BarChartRace.get_html5_video()

Convert the animation to an HTML5 <video> tag.

BarChartRace.get_interpolated_df(df, …)

Get interpolated dataframe to span total animation

BarChartRace.get_label_position()

Get label position for period annotation

BarChartRace.get_period_label(period_label)

Parameters for period annotation on charts, dict will be passed to kwargs in matplotlib.ax.text()

BarChartRace.get_single_color(color_string)

Get single RBGA value from string

BarChartRace.init_func()

Initialization function for animation

BarChartRace.make_animation(frames, init_func)

Method for creating animation

BarChartRace.plot_bars(i)

Plot bars in bar chart race on axes

BarChartRace.rename_data_columns(df)

Converts all column names to string

BarChartRace.save(filename)

Save method for FuncAnimation.

BarChartRace.set_x_y_limits(df, i, ax)

Set axis limits for both x and y of passed axes object

BarChartRace.setup_progress_bar()

Create an instance of alive-progress bar in manual mode

BarChartRace.show_period(i)

Show period label on plot

BarChartRace.update_progress_bar()

Update TQDM instance by 1

BarChartRace.validate_params()

Validate parameters provided to chart instance