src.visualise.visualise_utils

Utility functions, classes, and constants for creating figures and tables

Functions

alpha_func(pal)

Shade a color map by given alpha value (can be used in color bars etc)

append_count_in_rows_to_df(df_avg_slopes[, ...])

Appends empty rows to a dataframe corresponding with every second of the count-in where no notes were played.

bootstrap_mean_difference(a1, a2[, ...])

Helper function to bootstrap the mean difference between two arrays (a1, a2).

break_axis(ax1, ax2[, d])

Add a vertical breaks into two axis to show change in scale

create_normalised_cmap(slopes)

Create a normalised cmap between a minimum, median, and maximum value.

create_output_folder(out)

Create a folder to store the plots, with optional subdirectory.

create_scalar_cbar(norm)

Creates a scalar colourbar object to be placed on a figure

get_gridspec_array([fig, ncols])

Create an array of axes with unequal numbers of plots per row/column Returns an array that can be indexed in the same way as the array normally returned by plt.subplots()

get_significance_asterisks(p)

Converts a raw p-value into asterisks, showing significance boundaries.

interpolate_df_rows(df)

Adds additional rows to a tempo slope dataframe, used when upscaling video FPS.

load_from_disc(output_dir[, filename])

Try and load models from disc

plot_decorator(plotter)

Decorator applied to any plotting function.

resample(perf[, col, resample_window])

Resamples an individual performance dataframe to get mean of every second.

Classes

BasePlot(**kwargs)

Base plotting class from which others inherit

class src.visualise.visualise_utils.BasePlot(**kwargs)

Bases: object

Base plotting class from which others inherit

src.visualise.visualise_utils.alpha_func(pal) ListedColormap

Shade a color map by given alpha value (can be used in color bars etc)

src.visualise.visualise_utils.append_count_in_rows_to_df(df_avg_slopes: DataFrame, time_col: str = 'elapsed') DataFrame

Appends empty rows to a dataframe corresponding with every second of the count-in where no notes were played. Input dataframe should be in the format returned by average_bpms (i.e. average BPM across performers per second) Used when creating videos of tempo slopes.

src.visualise.visualise_utils.bootstrap_mean_difference(a1: Series, a2: Series, quantile: float = 0.025, n_boot: int = 10000)

Helper function to bootstrap the mean difference between two arrays (a1, a2). Number of bootstraps is given by the N_BOOT constant if not provided. Quantile is set to 2.5, for 95% confidence intervals.

src.visualise.visualise_utils.break_axis(ax1: Axes, ax2: Axes, d: float = 0.015) None

Add a vertical breaks into two axis to show change in scale

src.visualise.visualise_utils.create_normalised_cmap(slopes: list) TwoSlopeNorm

Create a normalised cmap between a minimum, median, and maximum value.

src.visualise.visualise_utils.create_output_folder(out)

Create a folder to store the plots, with optional subdirectory. Out should be a full system path.

src.visualise.visualise_utils.create_scalar_cbar(norm: TwoSlopeNorm) ScalarMappable

Creates a scalar colourbar object to be placed on a figure

src.visualise.visualise_utils.get_gridspec_array(fig: Optional[Figure] = None, ncols: int = 2) array

Create an array of axes with unequal numbers of plots per row/column Returns an array that can be indexed in the same way as the array normally returned by plt.subplots()

src.visualise.visualise_utils.get_significance_asterisks(p: float) str

Converts a raw p-value into asterisks, showing significance boundaries.

src.visualise.visualise_utils.interpolate_df_rows(df: DataFrame) DataFrame

Adds additional rows to a tempo slope dataframe, used when upscaling video FPS.

src.visualise.visualise_utils.load_from_disc(output_dir: str, filename: str = 'phase_correction_mds.p') list

Try and load models from disc

src.visualise.visualise_utils.plot_decorator(plotter: callable)

Decorator applied to any plotting function. Used to create a folder, save plot into this, then close it cleanly and exit.

src.visualise.visualise_utils.resample(perf: DataFrame, col: str = 'my_onset', resample_window: str = '1s') DataFrame

Resamples an individual performance dataframe to get mean of every second.