Visualization¶
- visualize_trace(df, stroke_indices, stroke_id, type='simple', trace_strategy=None, plot_name=None, plot=True, save_path=None, **kwargs)¶
Generates (and optionally saves) a plot visualizing the trace of a stroke.
- Parameters:
df (pd.DataFrame) – DataFrame containing the stroke data with ‘x’, ‘y and ‘timeStamp’ columns.
stroke_indices (list) – List of indices corresponding to the stroke in the DataFrame. Can be obtained using df.index
stroke_id (str) – Identifier for the stroke to be displayed in the title.
type (str) – The type of visualization strategy to use. Options are: “simple”, “info”, “optimal_line”, “full” or “standardized”.
trace_strategy (TraceVisualizationType) – Instead of stating the type, the visualization type can be passed as a string or as a newly implemented class.
plot_name (str?) – If provided, saves the plot to this file path.
plot (bool) – Whether to display the plot.
save_path (str?) – Directory path to save the plot if plot_name is provided. Must include file extension (supported formats: eps, jpeg, jpg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff, webp). If not provided, saves in the current working directory.
**kwargs – Additional arguments to pass to the visualization strategy.
- video_from_trace(df, user_id, outfile, width=640, height=480, fps=30, colored=False)¶
Generates a video visualizing the mouse trace of a user.
- Parameters:
df (pd.DataFrame) – DataFrame containing the mouse trace data with ‘x’, ‘y’, ‘eventType’, and ‘sessionId’ columns.
user_id (str/int) – Identifier of the user whose trace is to be visualized.
outfile (str) – Path to save the output video file.
width (int) – Width of the video frame.
height (int) – Height of the video frame.
fps (int) – Frames per second for the video.
colored (bool) – If True, applies a temperature gradient (green to red) to the trajectory line.
- Returns:
Saves the video file to the specified path.
- Return type:
None