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
Methods
BarChartRace.__init__
(df, …)Initialize self.
Animation function, removes all bars and updates legend/period annotation.
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
Calculate expanded dataframe to match length of animation
Function to remove all existing lines, collections, etc at the start of the animation AND after a save.
Create Bar chart figure
BarChartRace.get_colors
(cmap)Get array of colours from BaseChart.get_colors and shorten to number of bars
Get list of columns containing plottable numeric data to plot
Method for determining range of frames to animate.
Convert the animation to an HTML5 <video> tag.
Get interpolated dataframe to span total animation
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
Initialization function for animation
BarChartRace.make_animation
(frames, init_func)Method for creating animation
Plot bars in bar chart race on axes
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
Create an instance of alive-progress bar in manual mode
Show period label on plot
Update TQDM instance by 1
Validate parameters provided to chart instance