修改updatefcn函数
function Untitled
clear all
TT=[200601 200603 200605 200607];
Final_b=[0.27 0.37 0.35 0.46];
plot(TT',Final_b','-.b.');
set(gca,'xtick',TT);
set(gca,'xticklabel',TT);
dcm_obj = datacursormode(gcf);
set(dcm_obj,'UpdateFcn',@myfunction);
datacursormode on;
function output_txt = myfunction(obj,event_obj)
% Display the position of the data cursor
% obj Currently not used (empty)
% event_obj Handle to event object
% output_txt Data cursor text string (string or cell array of strings).
pos = get(event_obj,'Position');
output_txt = {['X: ',num2str(pos(1))],...
['Y: ',num2str(pos(2))]};
% If there is a Z-coordinate in the position, display it as well
if length(pos) > 2
output_txt{end+1} = ['Z: ',num2str(pos(3),4)];
end |