File Exchange

image thumbnail


version (7.09 KB) by Jonathan Lister
DTMCURSOR implements a cross hair with the ability to set and measure values from x and/or y datums.


Updated 29 Oct 2013

View License

Datum Cursor (DTMCURSOR) provides a graphical evaluation tool that produces a crosshair that displays its location in a figure annotation for quick inspection of data values. The user can also define x and/or y datums and measurement lines to calculate differences quickly. The difference is displayed either above or to the right of each measurement line. All text objects, except for datum labels, can be re-positioned via mouse. Changing datum location causes all measurements to update. Delta_y text font and edge color is the color of the line that you added a measurement to. Datums and measurement lines are draggable. I've tried to blend all the best of what I've learned from the submissions that inspired me. Many great features... give it a try. I hope you will find it to be "the" tool for data exploration.

Cite As

Jonathan Lister (2020). dtmcursor (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

Jonathan Lister


Add this case to the keypress function for the feature you requested. I'll submit it to the FEX if this is what you're looking for.

case 'm'
%return all the x and y measurements to caller
xdt = get(this.xdatum,'XData');
ydt = get(this.ydatum,'YData');

if ~isempty(xdt)
xd = xdt(1);
xd = [];

if ~isempty(ydt)
yd = ydt(1);
yd = [];

%collect all x measurement values
nx = numel(this.xmline);
xm = zeros(1,nx);
for i=1:nx
x = get(this.xmline(i),'xdata');
xm(i) = x(1);

%collect all y measurement values (non-scaled)
ny = numel(this.ymline);
ym = zeros(1,ny);
for i=1:ny
y = get(this.ymline(i),'ydata');
ym(i) = y(1);

sf = this.ScaleFactor;
ys = (ym-sf{2})/sf{1};

% return column vectors with the datum as fist
% value in vector followed by all measurement
% locations
y = [yd ys];
x = [xd xm];

Jonathan Lister

Kostas, I will try to look into your suggestion. Most of my development time has been with another language lately. I'd apreciate a good rating... might help me be motivated ;)


Thanks for this nice tool. Is there any way to export the x- and/or y- axis measurements to a workspsace variable? I believe that this is a must-have functionality.

Jonathan Lister

Previous comment applies to the next revision...

Jonathan Lister

When dtmcursor is on you can type Shift+n to toggle SnapToNearest on/off

Jonathan Lister

Yet another update on the way...

Jonathan Lister

A significant update has been submitted and should be available soon.


Added ability to export datum and measurement line locations to the base work space as vectors x_pos and y_pos.

Cursors can snap to data... delta-y can change color, added static methods, case insensitive parameter value pair input.

Added Keypress commands to control SnapToNearest and crosshair visability. Made datums and measurement lines draggable. Changed the default line and edge colors to red. Changed the default line style to solid.

corrected some comments in the file

Added many new properties, all text except for datum labels can be re-positioned via mouse. SnapToNearest causes the crosshair to be constrained to the closest line value. Use set(obj,'SnapToNearest',false) to turn that feature off.

Added labels to the X and Y datums. I had a dependency on a function called "draggable" that I eliminated. Cursor and delta value text can now be re-positioned by dragging with mouse.

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux