Plot functions
Description
These various functions allow to plot the data from the Sequence and Audio instances on graphs, or to plot statistics calculated using the Analysis functions.
Functions
- krajjat.plot_functions.single_joint_movement_plotter(sequence_or_sequences, joint_label='HandRight', measures='default', domain='time', window_length=7, poly_order=None, nperseg=None, welch_window='hann', align=True, timestamp_start=None, timestamp_end=None, xlim=None, ylim=None, time_format=True, figure_background_color=None, graph_background_color=None, line_color=None, line_width=1.0, show=True, path_save=None, verbosity=1, **kwargs)
Plots the x, y, z positions across time of the joint of one or more sequences, along with the distance travelled, velocity and absolute variations of acceleration.
Note
The values for distance travelled and velocity are, by definition, calculated between two timestamps. The acceleration is calculated between three timestamps. For simplification purposes, in these graphs, the values are plotted at the ending timestamp. In other words, the plotting of the distance and velocity values starts at the second timestamp, while the plotting for the acceleration starts at the third timestamp.
New in version 2.0.
- Parameters:
sequence_or_sequences (Sequence or list(Sequence)) – One or multiple sequence instances.
joint_label (str, optional) – The label of the joint from which to use the values to plot (default:
"HandRight").measures (str or list(str)) –
The name of a metric, or a list containing the name of multiple metrics, among:
For the x-coordinate:
"x","x_coord","coord_x", or"x_coordinate".For the y-coordinate:
"y","y_coord","coord_y", or"y_coordinate".For the z-coordinate:
"z","z_coord","coord_z", or"z_coordinate".For the consecutive distances:
"d","distances","dist","distance", or0.For the consecutive distances on the x-axis:
"dx"`, ``"distance_x","x_distance","dist_x", or"x_dist".For the consecutive distances on the y-axis:
"dy"`, ``"distance_y","y_distance","dist_y", or"y_dist".For the consecutive distances on the z-axis:
"dz"`, ``"distance_z","z_distance","dist_z", or"z_dist".For the velocity:
"v","vel","velocity","velocities","speed", or1.For the acceleration:
"a","acc","acceleration","accelerations", or2.For the jerk:
"j","jerk", or3.For the snap:
"s","snap","joust"or4.For the crackle:
"c","crackle", or5.For the pop:
"p","pop", or6.For any derivative of a higher order, set the corresponding integer.
This value can also be
"default"(default) and will in that case display a sub-selection made of the x, y and z coordinates, the consecutive distances, the velocity, and the acceleration.It is also possible to add the suffix
"_abs"after a specific measure to plot the absolute values of the measure.domain (str, optional) – Defines if to plot the movement in the time domain (“time”, default) or in the frequency domain (“frequency”).
window_length (int, optional) – The length of the window for the Savitzky–Golay filter when calculating a derivative (default: 7). See scipy.signal.savgol_filter for more info.
poly_order (int|None, optional) –
The order of the polynomial for the Savitzky–Golay filter. If set on None, the polynomial will be set to one over the derivative rank. See scipy.signal.savgol_filter for more info.
nperseg (int|None, optional) – Number of samples per segment for the power spectrum density calculation (in case domain is set to
"frequency"). This parameter is passed to scipy.signal.welch.welch_window (str, optional) –
The window to use when calculating the power spectrum density (in case domain is set to
"frequency"). This parameter is passed to scipy.signal.welch.align (bool, optional) – If this parameter is set on
"True"(default), and if the parametersequence_or_sequencesis a list containing more than one sequence instance, the function will try to check if one or more of the sequences provided is or are sub-sequences of others. If it is the case, the function will align the timestamps of the sequences for the plot. If only one sequence is provided, this parameter is ignored.timestamp_start (float or None, optional) – If defined, indicates at what timestamp to start to calculate the measure.
timestamp_end (float or None, optional) – If defined, indicates at what timestamp to finish to calculate the measure.
xlim (list(int|float)|None, optional) – If defined, indicates the timestamp range of frequency range on the x-axis for all subplots. If not defined, the values of xlim will take the values of timestamp_start and timestamp_end in the time domain, or
0and the half of the highest sequence frequency in the frequency domain.ylim (list(float) or list(list(float)) optional) – If defined, sets the lower and upper limits of the y-axis for all sub-graphs (e.g. [0, 1]). If this parameter is a list of lists, each sublist sets the limits for each sub-graph.
time_format (bool, optional) – Defines if the time on the x-axis should be shown in raw seconds (
False) or in a formattedmm:ss:ms.format (True, default). The format turns automatically tohh:mm:ssif more than 60 minutes of recording are plotted.figure_background_color (tuple or string or list, optional) – The color of the background of the whole figure. See Color codes for the color name guidelines. If more than one sequence is provided, this parameter should be a list with the color for each line.
graph_background_color (tuple or string or list, optional) – The color of the background of each graph. See Color codes for the color name guidelines. If more than one sequence is provided, this parameter should be a list with the color for each line.
line_color (tuple or string or list, optional) – The color of the line(s) in the graph. See Color codes for the color name guidelines. If more than one sequence is provided, this parameter should be a list with the color for each line.
line_width (float, optional) – The width of the plotted lines, in pixels (default: 1.0).
show (bool, optional) – If set on False, the function does not show the graph. This parameter can be set if the purpose of the function is to save the graph in a file, without having to halt the execution of the code when opening a window.
path_save (str or None optional) – If provided, the function will save the plot as a picture. The path should contain the folder, the name file, and one of the following extensions:
".png",".jpeg"or".bmp".verbosity (int, optional) –
Sets how much feedback the code will provide in the console output:
0: Silent mode. The code won’t provide any feedback, apart from error messages.
1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.
2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.
**kwargs (dict) – Any of the parameters accepted by matplotlib.pyplot.plot.
Examples
>>> sequence = Sequence("Sequences/Auge/sequence_01.tsv") >>> single_joint_movement_plotter(sequence, joint_label="HandRight", measures="default") >>> sequence_cj = sequence.correct_jitter(1, 5) >>> single_joint_movement_plotter([sequence, sequence_cj], joint_label="HandRight", measures=["d", "v", "a", "j"]) >>> single_joint_movement_plotter([sequence, sequence_cj], joint_label="HandRight", ... measures=["d", "v", "a", "j"], domain="frequency", x_start=1, x_end=2, ... ylim=[[0, 4e-5], [0, 0.003], [0, 0.35], [0, 50]], line_width=2, ... line_color=["bcbl blue", "bcbl dark blue"], verbosity=1)
- krajjat.plot_functions.joints_movement_plotter(sequence_or_sequences, measure='velocity', domain='time', window_length=7, poly_order=None, nperseg=None, welch_window='hann', audio_or_derivative=None, overlay_audio=False, audio_color='#a102db', align=True, timestamp_start=None, timestamp_end=None, xlim=None, ylim=None, line_width=1.0, color_scheme='default', show_scale=False, show=True, path_save=None, verbosity=1, **kwargs)
Plots the distance or velocity across time of the joints, in separate sub-graphs whose localisation roughly follows the original body position of the joints.
New in version 2.0.
- Parameters:
sequence_or_sequences (Sequence or list(Sequence)) – One or multiple sequence instances.
measure (str, optional) –
This parameter can take the following values:
For the x-coordinate:
"x","x_coord","coord_x", or"x_coordinate".For the y-coordinate:
"y","y_coord","coord_y", or"y_coordinate".For the z-coordinate:
"z","z_coord","coord_z", or"z_coordinate".For the consecutive distances:
"d","distances","dist","distance", or0.For the consecutive distances on the x-axis:
"dx"`, ``"distance_x","x_distance","dist_x", or"x_dist".For the consecutive distances on the y-axis:
"dy"`, ``"distance_y","y_distance","dist_y", or"y_dist".For the consecutive distances on the z-axis:
"dz"`, ``"distance_z","z_distance","dist_z", or"z_dist".For the velocity:
"v","vel","velocity","velocities","speed", or1.For the acceleration:
"a","acc","acceleration","accelerations", or2.For the jerk:
"j","jerk", or3.For the snap:
"s","snap","joust"or4.For the crackle:
"c","crackle", or5.For the pop:
"p","pop", or6.For any derivative of a higher order, set the corresponding integer.
This value can also be
"default"(default) and will in that case display a sub-selection made of the x, y and z coordinates, the consecutive distances, the velocity, and the acceleration.It is also possible to add the suffix
"_abs"after a specific measure to plot the absolute values of the measure.domain (str, optional) – Defines if to plot the movement in the time domain (“time”, default) or in the frequency domain (“frequency”).
window_length (int, optional) –
The length of the window for the Savitzky–Golay filter when calculating a derivative (default: 7). See scipy.signal.savgol_filter for more info.
poly_order (int|None, optional) –
The order of the polynomial for the Savitzky–Golay filter. If set on None, the polynomial will be set to one over the derivative rank. See scipy.signal.savgol_filter for more info.
nperseg (int|None, optional) –
Number of samples per segment for the power spectrum density calculation (in case domain is set to
"frequency"). This parameter is passed to scipy.signal.welch.welch_window (str, optional) –
The window to use when calculating the power spectrum density (in case domain is set to
"frequency"). This parameter is passed to scipy.signal.welch.audio_or_derivative (Audio, AudioDerivative or None, optional) – An Audio instance, or any of the AudioDerivative child classes (
Envelope,Pitch,IntensityorFormant). If provided, the samples of the object will be plotted in the top-left corner.overlay_audio (bool, optional) – If set on
True, and if audio_or_derivative is not None, the samples of theaudio_or_derivativeobject will be shown on overlay of the different joint velocities.audio_color (str, optional) – The color of the audio samples if
overlay_audiois set onTrue(default: “#a102db”).align (bool, optional) – If this parameter is set on
"True"(default), and if the parametersequence_or_sequencesis a list containing more than one sequence instance, the function will try to check if one or more of the sequences provided is or are sub-sequences of others. If it is the case, the function will align the timestamps of the sequences for the plot. If only one sequence is provided, this parameter is ignored.timestamp_start (float or None, optional) – If defined, indicates at what timestamp to start to calculate the measure.
timestamp_end (float or None, optional) – If defined, indicates at what timestamp to finish to calculate the measure.
xlim (list(int|float)|None, optional) – If defined, indicates the timestamp range of frequency range on the x-axis for all subplots. If not defined, the values of xlim will take the values of timestamp_start and timestamp_end in the time domain, or
0and the half of the highest sequence frequency in the frequency domain.ylim (list(int|float)|None, optional) – If defined, sets the lower and upper limits of the y-axis for all sub-graphs (e.g. [0, 1]). If this parameter is a list of lists, each sublist sets the limits for each sub-graph.
line_width (float, optional) – The width of the plotted lines, in pixels (default: 1.0).
color_scheme (string or list, optional) – The name of a color scheme or a list of colors to create a gradient. The resulting color gradient will be used to color the joints plots depending on their quantity of movement. If set on
"default", the default color scheme will be used, with the joints having the highest quantity of movement colored red. If a list of colors is set as parameter, the colors can be specified in RGB, RGBA, hexadecimal or standard HTML/CSS color names. In the case where multiple sequences are passed as parameter, this parameter should contain a list of colors, for each sequence.show_scale (bool, optional) – If set on
True, shows a colored scale on the left side of the graph.show (bool, optional) – If set on False, the function does not show the graph. This parameter can be set if the purpose of the function is to save the graph in a file, without having to halt the execution of the code when opening a window.
path_save (str or None optional) – If provided, the function will save the plot as a picture. The path should contain the folder, the name file, and one of the following extensions:
".png",".jpeg"or".bmp".verbosity (int, optional) –
Sets how much feedback the code will provide in the console output:
0: Silent mode. The code won’t provide any feedback, apart from error messages.
1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.
2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.
**kwargs (dict) –
Any of the parameters accepted by matplotlib.pyplot.plot.
Examples
>>> sequence = Sequence("Sequences/Anatolê/sequence_02.tsv") >>> joints_movement_plotter(sequence, measure="velocity", domain="time", verbosity=0) >>> sequence_cj = sequence.correct_jitter(1, 5) >>> joints_movement_plotter([sequence, sequence_cj], measure="velocity_abs", domain="time", verbosity=0) >>> audio = Audio("Sequences/Anatolê/sequence_02.wav", verbosity=0) >>> joints_movement_plotter(sequence_cj, measure="velocity", domain="time", audio_or_derivative=audio, ... overlay_audio=True, verbosity=0)
- krajjat.plot_functions.framerate_plotter(sequence_or_sequences, line_width=1.0, line_color='black', show=True, path_save=None, **kwargs)
Plots the framerates across time for one or multiple sequences. The framerate is calculated by getting the inverse of the time between consecutive poses.
New in version 2.0.
- Parameters:
sequence_or_sequences (Sequence or list(Sequence)) – One or multiple sequence instances.
line_width (float, optional) – The width of the plotted lines, in pixels (default: 1.0).
line_color (tuple(int, int, int) or tuple(int, int, int, int) or string) –
The color of the line in the graph. This parameter can be:
A HTML/CSS name (e.g.
"red"or"blanched almond"),An hexadecimal code, starting with a number sign (
#, e.g."#ffcc00"or"#c0ffee").A RGB or RGBA tuple (e.g.
(153, 204, 0)or(77, 77, 77, 255)).
show (bool, optional) – If set on False, the function does not show the graph. This parameter can be set if the purpose of the function is to save the graph in a file, without having to halt the execution of the code when opening a window.
path_save (str or None optional) – If provided, the function will save the plot as a picture. The path should contain the folder, the name file, and one of the following extensions:
".png",".jpeg"or".bmp".**kwargs (dict) –
Any of the parameters accepted by matplotlib.pyplot.plot.
Examples
>>> sequence = Sequence("Sequences/Musica/sequence_02.csv", verbosity=0) >>> framerate_plotter(sequence) >>> sequence_rs = sequence.resample(20, "cubic", verbosity=0) >>> framerate_plotter([sequence, sequence_rs])
- krajjat.plot_functions.audio_plotter(audio, filter_below=None, filter_over=None, number_of_formants=3, show=True, path_save=None, verbosity=1)
Given an audio instance, plots the samples, filtered envelope, pitch, intensity, formants and spectrogram.
New in version 2.0.
- Parameters:
audio (Audio) – An Audio instance.
filter_below (int, float or None, optional) – If not
Nonenor 0, this value will be provided as the lowest frequency of the band-pass filter.filter_over (int, float or None, optional) – If not
Nonenor 0, this value will be provided as the highest frequency of the band-pass filter.number_of_formants (int, optional) – The number of formants to plot (default: 3).
show (bool, optional) – If set on False, the function does not show the graph. This parameter can be set if the purpose of the function is to save the graph in a file, without having to halt the execution of the code when opening a window.
path_save (str or None optional) – If provided, the function will save the plot as a picture. The path should contain the folder, the name file, and one of the following extensions:
".png",".jpeg"or".bmp".verbosity (int, optional) –
Sets how much feedback the code will provide in the console output:
0: Silent mode. The code won’t provide any feedback, apart from error messages.
1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.
2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.
Warning
With non-resampled audio files, this function can take several minutes to compute before being able to plot the graphs. It is recommended to perform a downsampling of the audio object before running this function.
Example
>>> audio = Audio("Sequences/Gymnastica/recording_gymnastica.wav", verbosity=0) >>> audio_plotter(audio, filter_over=50, verbosity=0)
- krajjat.plot_functions.plot_body_graphs(plot_dictionary, joint_layout='auto', title=None, min_scale=None, max_scale=None, show_scale=False, title_scale=None, xlim=None, ylim=None, shaded_error_bars=True, alpha_shade=0.4, color_scheme='default', title_audio='Audio', full_screen=False, show=True, path_save=None, **kwargs)
Creates multiple subplots placed so that each joint is roughly placed where it is located on the body. The values of each subplot are taken from the parameter
plot_dictionary, and the positions from the layout differ between Kinect and Kualisys systems.New in version 2.0.
- Parameters:
plot_dictionary (dict(str: Graph)) – A dictionary containing the title of the subgraphs as keys, and Graph objects as elements.
joint_layout (str, optional) –
Defines the layout to use for the subplots of the joints:
"kinect","qualisys"/"kualisys", or the path to a file containing a custom layout. If set on"auto"(default), the function will automatically assign the layout depending on if the joint label"Chest"is among the keys of theplot_dictionary.The joint layouts are a grid of 7 × 5 subplots for Kinect, and 13 × 7 subplots for Qualisys. The corresponding spots for each joint are loaded from
"res/kinect_joints_subplot_layout.txt"and"res/kualisys_joints_subplot_layout.txt".title (str or None, optional) – The title to display on top of the plot.
min_scale (float or None, optional) – The minimum value to set on the y-axis, for all the elements in the
plot_dictionarythat match joint keys (i.e., except from the subplot under the"Audio"key). If set on None (default), the minimum value will be the overall minimum value from theplot_dictionary, with the subgraph"Audio"excluded.max_scale (float or None, optional) – The maximum value to set on the y-axis, for all the elements in the
plot_dictionarythat match joint keys (i.e., except from the subplot under the"Audio"key). If set on None (default), the maximum value will be the overall minimum value from theplot_dictionary, with the subgraph"Audio"excluded.show_scale (bool, optional) – If set on
True, shows a colored scale on the right side of the graph.title_scale (str or None, optional) – Defines a title to give to the scale, if
show_scaleis set onTrue.xlim (list(float, float)|None, optional) – If set, defines the lower and upper limits of the x-axis of the sub-graphs (default: None).
ylim (list(float, float)|None, optional) – If set, defines the lower and upper limits of the y-axis of the sub-graphs (default: None).
shaded_error_bars (bool, optional) – Shows shaded error bars for each plot if the standard deviation is part of the plot_dictionary. Default: True.
alpha_shade (float, optional) – The alpha value for the color of the shaded error bars. Default: 0.4.
color_scheme (str or list, optional) – The color scheme to use for the color scale. This color scheme should be coherent with the colors defined in the
plot_dictionary.title_audio (str or None, optional) – The title to give to the sub-plot that matches the key
"Audio"from theplot_dictionary. This sub-plot is located in the top-left corner of the plot, and is not scaled the same way as the other plots. By default, the title of this sub-plot is"Audio", but this parameter allows to change the title to put the name of an AudioDerivative type, such as"Envelope"or"Pitch", for example.full_screen (bool, optional) – If set on True, shows the figure in full screen. By default, set on False.
show (bool, optional) – If set on False, the function does not show the graph. This parameter can be set if the purpose of the function is to save the graph in a file, without having to halt the execution of the code when opening a window.
path_save (str or None) – If not None, the function saves the obtained graph at the given path.
**kwargs (dict) –
Any of the parameters accepted by matplotlib.pyplot.plot.
Example
>>> plot_dictionary = {} >>> plot_dictionary["Head"] = Graph() >>> plot_dictionary["Head"].add_plot(np.linspace(0, 10, 11), np.linspace(0, 10, 11), None, 1, "red", "x=y") >>> plot_dictionary["HandRight"] = Graph() >>> plot_dictionary["HandRight"].add_plot(np.linspace(0, 10, 11), np.linspace(0, 10, 11), None, 1, "green", "x=y") >>> plot_dictionary["HandLeft"] = Graph() >>> plot_dictionary["HandLeft"].add_plot(np.linspace(0, 10, 11), np.linspace(0, 10, 11), None, 1, "blue", "x=y") >>> plot_dictionary["HandLeft"].add_plot(np.linspace(0, 10, 11), np.linspace(10, 0, 11), None, 2, "orange", "y=x") >>> plot_body_graphs(plot_dictionary, joint_layout="auto")
- krajjat.plot_functions.plot_silhouette(plot_dictionary, joint_layout='auto', title=None, title_silhouette=None, scale_silhouette=0.9, min_scale='auto', max_scale='auto', show_scale=True, title_scale=None, color_scheme='default', color_background='white', color_silhouette='black', pixels_between_silhouettes=100, path_font=None, font_size=1, resolution=0.5, full_screen=False, show=True, path_save=None, verbosity=1, **kwargs)
Plots one or multiple silhouettes with circles representing the different joints, colored according to their values in the
plot_dictionary. Passing the mouse on the different joints shows, in the bottom right corner, the value associated to the joint the mouse is on.New in version 2.0.
- Parameters:
plot_dictionary (dict(str: float|np.array)) – A dictionary containing the title of the sub-graphs as keys, and values as elements. The number of silhouettes displayed will depend on the number of values in each value of the plot dictionary: if there is only one value, one silhouette is displayed; if the value is an array, the function will display as many silhouettes as the size of the arrays.
joint_layout (str, optional) –
Defines the layout to use for the sub-plots of the joints:
"kinect"or"qualisys"/"kualisys". If set on"auto"(default), the function will automatically assign the layout depending on if the joint label"Chest"is among the keys of theplot_dictionary. In order to create a personalized layout, it is possible to click on the figure to print in the console a specific position. Pressing the CTRL key at the same time allows to display a test circle where the mouse is located, to give an idea of the render.The joint layouts are a grid of 7 × 5 sub-plots for Kinect, and 13 × 7 subplots for Qualisys. The corresponding spot for each joint are loaded from
"res/kinect_joints_subplot_layout.txt"and"res/kualisys_joints_subplot_layout.txt".title (str or None, optional) – The title to display on top of the plot.
title_silhouette (str | list | None (optional)) – The title to set for each silhouette. If a list is provided, the length must be equal to the number of elements in each value of the
plot_dictionary.scale_silhouette (float (optional)) – The scale of each silhouette in the window. If set on 1, the silhouette will take the total height of the window. The default value is 0.9, in order to leave place for titles.
min_scale (str or float, optional) – If set on
"auto"(default), the lowest value of the scale will be set on the lowest value in theplot_dictionary. If set on a number, all the values below that number will be colored will the color matching this parameter on the scale.max_scale (str or float, optional) – If set on
"auto"(default), the highest value of the scale will be set on the highest value in theplot_dictionary. If set on a number, all the values above that number will be colored will the color matching this parameter on the scale.show_scale (bool, optional) – If set on
True, shows a colored scale on the left side of the graph.title_scale (str or None, optional) – Defines a title to give to the scale, if
show_scaleis set onTrue.color_scheme (str or list, optional) –
The color scheme of the scale. This parameter can take a number of forms:
The name of a color scheme: a string matching one of the color gradients available in Color schemes (default:
"default").A list of colors: a list containing colors, either using:
Their HTML/CSS names (e.g.
"red"or"blanched almond"),Their hexadecimal code, starting with a number sign (
#, e.g."#ffcc00"or"#c0ffee").Their RGB or RGBA tuples (e.g.
(153, 204, 0)or(77, 77, 77, 255)).
These different codes can be used concurrently, e.g.
["red", (14, 18, 32), "#a1b2c3"].
color_background (str, tuple(int, int, int) or tuple(int, int, int, int), optional) –
The color of the background (default:
"white"). This parameter can be a tuple with RGB or RGBA values, a string with a hexadecimal value (starting with a leading#) or one of the standard HTML/CSS color names.color_silhouette (str, tuple(int, int, int) or tuple(int, int, int, int), optional) –
The color of the silhouette (default:
"black"). This parameter can be a tuple with RGB or RGBA values, a string with a hexadecimal value (starting with a leading#) or one of the standard HTML/CSS color names.pixels_between_silhouettes (int, optional) – The amount of pixels separating two silhouettes, if more than one silhouette is shown (default: 100).
path_font (str or None, optional) – If set, defines the path to any TTF or OTF font. This font will be used for the title, the silhouette titles and the scale titles and values. If set on None (default), the built-in font junction-bold.otf will be used.
font_size (int | tuple, optional) – The size of the font for the title, the silhouette titles and the scale. The default value is 1, which is an arbitrary value that is equal to 4% of the height of the window. This parameter can be set on a tuple of three values
(a, b, c)whereαis the size of the title,bthe size of the silhouette titles, andcthe size of the scale titles and values.resolution (tuple(int, int) or float or None, optional) –
The resolution of the Pygame window that will display the silhouette. This parameter can be:
A tuple with two integers, representing the width and height of the window in pixels.
A float, representing the ratio of the total screen width and height; for example, setting this parameter on 0.5 on a screen that is 1920 × 1080 pixels will create a window of 960 × 540 pixels. Note: if a video is provided and set on the side of the sequence, or if two sequences are provided, side by side, the horizontal resolution will be set to be twice the size. A parameter of 0.5 on a screen that is 1920 × 1080 pixels will, in that case, create a window of 1920 × 540 pixels.
None: in that case, the window will be the size of the screen.
full_screen (bool, optional) – Defines if the window will be set full screen (
True) or not (False, default).show (bool, optional) – If set on False, the function does not show the graph. This parameter can be set if the purpose of the function is to save the graph in a file, without having to halt the execution of the code when opening a window.
path_save (str or None optional) – If provided, the function will save the silhouette as a picture. The path should contain the folder, the name file, and one of the following extensions:
".png",".jpeg"or".bmp".verbosity (int, optional) –
Sets how much feedback the code will provide in the console output:
0: Silent mode. The code won’t provide any feedback, apart from error messages.
1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.
2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.
**kwargs (dict) –
Any of the parameters accepted by matplotlib.pyplot.plot.
Example
>>> plot_dictionary = {"Head": 0.1, "HandRight": 0.48, "HandLeft": 0.88} >>> plot_silhouette(plot_dictionary, joint_layout="auto", title="Coherence", min_scale=0, max_scale=1, ... show_scale=True, title_scale="Coherence scale (A.U.)", color_scheme="horizon", ... color_background="black", color_silhouette="#303030", verbosity=0)
Private function
- krajjat.plot_functions._plot_components(pca_or_ica, components, joint_labels, title, selected_components=None)
Plots the components of a PCA or an ICA.
New in version 2.0.
- Parameters:
pca_or_ica (numpy.ndarray) – The components returned by a Principal Component Analysis.
components (numpy.ndarray) – The components attribute of the PCA, containing the directions of maximum variance in the data for each feature (the joint labels).
joint_labels (list(str)) – The labels of each feature.
title (str) – The title of the figure.
selected_components (int, list(int) or None) – If set, plots only the selected component(s). The components start at index 0.
- krajjat.plot_functions._prepare_plot_timestamps(sequence_or_sequences, align, verbosity)
Returns the timestamps, aligned or not, from one or multiple Sequence instances.
New in version 2.0.
- Parameters:
sequence_or_sequences (Sequence or list(Sequence)) – One or multiple sequence instances.
align (bool, optional) – If this parameter is set on
"True"(default), and if the parametersequence_or_sequencesis a list containing more than one sequence instance, the function will try to check if one or more of the sequences provided is or are sub-sequences of others. If it is the case, the function will align the timestamps of the sequences for the plot. If only one sequence is provided, this parameter is ignored.verbosity (int, optional) –
Sets how much feedback the code will provide in the console output:
0: Silent mode. The code won’t provide any feedback, apart from error messages.
1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.
2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.
- Returns:
list(Sequence) – A list containing the Sequence instances passed as parameter. If only one Sequence was passed, a list containing only this Sequence is returned.
list(numpy.array(float)) – A list of timestamps from each of the Sequence instances (in the same order as they were passed as parameters).
- krajjat.plot_functions._calculate_plot_limits(sequences, timestamps, domain, timestamp_start, timestamp_end, xlim, verbosity)
Given a list of sequences and their timestamps, sets:
The starting and ending timestamps for the measure calculations, if they weren’t defined.
The limit on the x-axis, if it wasn’t manually defined.
New in version 2.0.
- Parameters:
sequences (list(Sequence)) – A list of Sequence instances.
timestamps (list(np.ndarray)) – A list of timestamps from the Sequence instances.
domain (str, optional) – Defines if to plot the movement in the time domain (“time”, default) or in the frequency domain (“frequency”).
timestamp_start (float or None, optional) – If defined, indicates at what timestamp to start to calculate the measure.
timestamp_end (float or None, optional) – If defined, indicates at what timestamp to finish to calculate the measure.
xlim (list(float|None, float|None)) –
The limits of the plot on the x-axis. If set, this parameter will be returned as is. Otherwise, the calculation of the limit of the x-axis depends on the domain:
If domain is set on
"time", the limits are set on the timestamp_start and timestamp_end values.If domain is set on
"frequency", the limits are set on 0 and half of the highest Sequence frequency.
verbosity (int, optional) –
Sets how much feedback the code will provide in the console output:
0: Silent mode. The code won’t provide any feedback, apart from error messages.
1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.
2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.