wildboar.utils.plot#
Module Contents#
Classes#
Normalise the colorbar. |
Functions#
|
Plot the samples in the freqency domain |
|
Plot the samples in the time domain |
Attributes#
- class wildboar.utils.plot.MidpointNormalize(vmin=None, vmax=None, midpoint=None, clip=False)[source]#
Bases:
matplotlib.colors.NormalizeNormalise the colorbar.
- Parameters:
vmin (float or None) – If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e.,
__call__(A)callsautoscale_None(A).vmax (float or None) – If vmin and/or vmax is not given, they are initialized from the minimum and maximum value, respectively, of the first input processed; i.e.,
__call__(A)callsautoscale_None(A).clip (bool, default: False) –
Determines the behavior for mapping values outside the range
[vmin, vmax].If clipping is off, values outside the range
[vmin, vmax]are also transformed linearly, resulting in values outside[0, 1]. For a standard use with colormaps, this behavior is desired because colormaps mark these outside values with specific colors for over or under.If
Truevalues falling outside the range[vmin, vmax], are mapped to 0 or 1, whichever is closer. This makes these values indistinguishable from regular boundary values and can lead to misinterpretation of the data.
Notes
Returns 0 if
vmin == vmax.- __call__(value, clip=None)[source]#
Normalize value data in the
[vmin, vmax]interval into the[0.0, 1.0]interval and return it.- Parameters:
value – Data to normalize.
clip (bool, optional) –
See the description of the parameter clip in .Normalize.
If
None, defaults toself.clip(which defaults toFalse).
Notes
If not already initialized,
self.vminandself.vmaxare initialized usingself.autoscale_None(value).
- wildboar.utils.plot.plot_frequency_domain(x, y=None, *, ax=None, n_samples=100, jitter=False, sample_spacing=1, frequency=False, cmap='Dark2')[source]#
Plot the samples in the freqency domain
- Parameters:
x (array-like of shape (n_sample, n_timestep)) – The samples
y (array-like of shape (n_samples, ), optional) – The labels, by default None
ax (Axes, optional) – The matplotlib Axes-object, by default None
jitter (bool, optional) – Add jitter to the amplitude lines, by default False
sample_spacing (int, optional) – The frequency domain sample spacing, by default 1
frequency (bool, optional) – Show the frequency bins, by default False
cmap (str, optional) – The colormap, by default “Dark2”
- wildboar.utils.plot.plot_time_domain(x, y=None, *, n_samples=100, ax=None, alpha=0.5, linewidth=0.5, zorder=-1, cmap='Dark2', show_legend=8)[source]#
Plot the samples in the time domain
- Parameters:
x (array-like of shape (n_sample, n_timestep)) – The samples
y (array-like of shape (n_samples, ), optional) – The labels
n_samples (int, optional) – The maximum number of samples to plot. If n_samples is larger than the number of samples in x or None, all samples are plotted.
ax (Axes, optional) – The matplotlib Axes-object
alpha (float, optional) – The opacity of the samples.
linewidth (float, optional) – The width of the sample lines.
zorder (int, optional) – The order where the samples are plotted. By default we plot the samples at -1.
cmap (str, optional) – The colormap used to colorize samples according to its label.
show_legend (bool or int, optional) –
Whether the legend of labels are show.
if bool, show the legend if y is not None
if int, show the legend if the number of labels are lower than the show_legend parameter value
- Returns:
ax – The axes object that has been plotted.
- Return type:
Axes