DateTimeRectangle¶
- DateTimeRectangle()¶
DATETIMERECTANGLE Interactive draggable and resizable rectangle with datetime support
- Usage:
rect = DateTimeRectangle(ax, pos, callback) rect = DateTimeRectangle(ax, pos, callback, ‘Name’, Value, …)
- Inputs:
ax : axes handle - target axes – required pos : struct with fields x (datetime/double), y (double),
width (duration/double), height (double) – required
callback : function handle - called with updated pos on every change – required
- Name-Value Pairs:
‘LineColor’ : 1x3 double - RGB border color (default: [0 0.4 1]) ‘LineWidth’ : double - border width (default: 2) ‘FaceAlpha’ : double - patch transparency (default: 0.2) ‘HandleSize’ : double - marker size for resize handles (default: 10) ‘ConstraintFcn’ : function handle - custom constraint @(pos)pos (default: []) ‘ConstrainToAxis’ : logical - keep rectangle inside axis limits (default: true) ‘FullHeight’ : logical - force rectangle to span full y-limits (default: false) ‘FullWidth’ : logical - force rectangle to span full x-limits (default: false)
- Outputs:
rect : DateTimeRectangle handle object
Notes
Supports dragging (inside), corner resizing, edge resizing, datetime- safe hit testing, and automatic cursor updates. Observable properties repaint the graphics on assignment. All listeners and callbacks are cleaned up on deletion.
Example
ax = axes; plot(ax, datetime(2023,1,1)+days(0:100), rand(1,101)); pos.x = datetime(2023,1,10); pos.y = 0.2; pos.width = days(20); pos.height = 0.5; rect = DateTimeRectangle(ax, pos, @(p)disp(p));
See also: DateTimeLine, EventMarker
∿∿∿ Prerau Laboratory MATLAB Codebase · sleepEEG.org ∿∿∿