image thumbnail
from correct tick label by benharper1977
set x tick label in a desired format and maintain it when zooming, panning or using data cursor

correct_figure()
function [] = correct_figure()

zM = zoom(gcf);
set(zM, 'ActionPostCallback', ...
@(figh, eventobj) set(eventobj.Axes, 'XTickLabel', ...
sprintf('%d|', get(eventobj.Axes, 'XTick'))));

pN = pan(gcf);
set(pN, 'ActionPostCallback', ...
@(figh, eventobj) set(eventobj.Axes, 'XTickLabel', ...
sprintf('%d|', get(eventobj.Axes, 'XTick'))));

fig=gcf;
dcm_obj = datacursormode(fig);
set(dcm_obj,'UpdateFcn',@myupdatefcn)

function [txt] = myupdatefcn(empt,eventdata)
    pos = get(eventdata,'Position');
    txt = {['Sample: ',num2str(pos(1))],...
          ['Value: ',num2str(pos(2))]};
end   

end

Contact us at files@mathworks.com