wildboar.utils.plot
#
Plotting utilities.
Module Contents#
Classes#
Normalise values with a specified midpoint. |
Functions#
|
Plot the samples in the freqency domain. |
|
Plot the samples in the time domain. |
- class wildboar.utils.plot.MidpointNormalize(vmin=None, vmax=None, midpoint=None)[source]#
Normalise values with a specified midpoint.
- Parameters:
- vminfloat, optional
The minumum value.
- vmaxfloat, optional
The maximum value.
- midpointfloat, optional
The midpoint of the values.
- inverse(value)[source]#
Maps the normalized value (i.e., index in the colormap) back to image data value.
- Parameters:
- value
Normalized value.
- static process_value(value)[source]#
Homogenize the input value for easy and efficient normalization.
value can be a scalar or sequence.
- Parameters:
- value
Data to normalize.
- Returns:
- resultmasked array
Masked array with the same shape as value.
- is_scalarbool
Whether value is a scalar.
Notes
Float dtypes are preserved; integer types with two bytes or smaller are converted to np.float32, and larger types are converted to np.float64. Preserving float32 when possible, and using in-place operations, greatly improves speed for large arrays.
- 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:
- xarray-like of shape (n_sample, n_timestep)
The samples.
- yarray-like of shape (n_samples, ), optional
The labels.
- axAxes, optional
The matplotlib Axes-object.
- n_samplesint, 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.
- jitterbool, optional
Add jitter to the amplitude lines.
- sample_spacingint, optional
The frequency domain sample spacing.
- frequencybool, optional
Show the frequency bins.
- cmapstr, optional
The colormap.
- Returns:
- Axes
The axes object that has been plotted.
Examples
>>> from wildboar.utils.plot import plot_frequency_domain >>> from wildboar.datasets import load_gun_point >>> X, y = load_gun_point(X, y) >>> plot_frequency_domain(X, y, n_sample=10)
- 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:
- xarray-like of shape (n_sample, n_timestep)
The samples.
- yarray-like of shape (n_samples, ), optional
The labels, assumed to be discrete labels.
- n_samplesint, 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.
- axAxes, optional
The matplotlib Axes-object.
- alphafloat, optional
The opacity of the samples.
- linewidthfloat, optional
The width of the sample lines.
- zorderint, optional
The order where the samples are plotted. By default we plot the samples at -1.
- cmapstr, optional
The colormap used to colorize samples according to its label.
- show_legendbool 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:
- Axes
The axes object that has been plotted.
Examples
>>> from wildboar.utils.plot import plot_time_domain >>> from wildboar.datasets import load_gun_point >>> X, y = load_gun_point(X, y) >>> plot_time_domain(X, y, n_sample=10)