The following code
fig = figure;z = peaks;z=z(20:25,40:43);bar(z,'stack');
produces a plot in which the data cursor displays three values: X, Y (Stacked), Y (Segment).
If I create a 'UpdateFcn' for the datacursormode object then I only have access to two values through the 'Position' property: X and Y (Stacked). This is illustrated by the following code:
function doc_datacursormodefig = figure;z = peaks;z=z(20:25,40:43);bar(z,'stack');dcm_obj = datacursormode(fig);set(dcm_obj,'UpdateFcn',@myupdatefcn);function txt = myupdatefcn(empt,event_obj)pos = get(event_obj,'Position');txt = {['X: ',num2str(pos(1))],...['Y (Stacked): ',num2str(pos(2))]};
I would also like to have access to the Y (Segment) value, which the default data cursors show.
Best Answer