shnitsel.vis.datasheet.figures.hist

Functions

calc_truncation_maximum(data[, rel_cutoff, bins])

Function to calculate the upper cutoff-threshold of data such that

truncate_from_above(data[, rel_cutoff, bins])

Helper function to truncate the data array on the upper end by a threshold

create_marginals(ax)

Function to create a pair of axes on top of and beside the axes passed as an argument to plot additional

create_marginals_dict(axs, label)

Function to add a set of marginal axes with create_marginals() for the axes at key label in axs

Module Contents

calc_truncation_maximum(data, rel_cutoff=0.01, bins=1000)

Function to calculate the upper cutoff-threshold of data such that the frequency in the last bin is at least rel_cutoff times the maximum frequency.

Helps to limit outliers.

Parameters:
  • data – The data that should be histogrammed and filtered.

  • rel_cutoff (float, optional) – Factor relative to the frequency maximum that should be used for determining the cutoff. Defaults to 0.01.

  • bins (int, optional) – How many bins should be used for getting the correct threshold location. Defaults to 1000.

Returns:

Upper cutoff position to stay above the rel_cutoff relative threshold.

Return type:

float

truncate_from_above(data, rel_cutoff=0.01, bins=1000)

Helper function to truncate the data array on the upper end by a threshold such that the histogram frequency stays above rel_cutoff*max(frequency) and is below this relative cutoff above the cutoff.

Parameters:
  • data (numpy.typing.NDArray) – The data that should be histogrammed and filtered.

  • rel_cutoff (float, optional) – Factor relative to the frequency maximum that should be used for determining the cutoff. Defaults to 0.01.

  • bins (int, optional) – How many bins should be used for getting the correct threshold location. Defaults to 1000.

Returns:

The filtered data array

Return type:

npt.NDArray

create_marginals(ax)

Function to create a pair of axes on top of and beside the axes passed as an argument to plot additional data into.

Generally used for plotting dimension-specific histograms next to xy-plots.

Parameters:

ax (Axes) – Axes to create marginal plots inside of

Returns:

Resulting pair of outset axes.

Return type:

tuple[Axes, Axes]

create_marginals_dict(axs, label)

Function to add a set of marginal axes with create_marginals() for the axes at key label in axs and add the marginal axes back into the dict with appended x and y suffixes.

Parameters:
  • axs (dict[str, Axes]) – Dict of axes from which to pick the axis object and amend with marginal axes.

  • label (str) – Key in axs for which the marginal axes should be created.

Returns:

axs but with the new marginal axes inserted at {label}x and `{label}y.

Return type:

dict[str, Axes]