change in Datacursor mode disappear while open the saved figure
2 次查看(过去 30 天)
显示 更早的评论
I have used Matlab 2014. I have changed the data cursor text using datacursormode and it's associated functions (e.g.UpdateFcn). And The data cursor text was changed successfully. but the problem is that after saving the figure, when I open the figure, it shows the default data cursor text.
Can anyone kindly help me out? How to get the changed data cursor text when open the saved figure?
snippet of code:
h_im=imagesc(flipud(transpose(wafermap)));
set(h_im,'userdata',wafermap) % find the handle for the data cursor; set the update function dcmH = datacursormode(gcf); set(dcmH,'UpdateFcn',@cursorUpdateFcn)
function output_txt = cursorUpdateFcn(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).
% position of the data point to label pos = get(event_obj,'Position');
data = get(get(event_obj,'Target'),'UserData');
pos(2)=43-pos(2)+1;%%%
% create the text to be displayed
output_txt = {
['X_value: ',num2str(pos(1),4)];...
['Y_value: ',num2str(pos(2),4)];...
['Data: ',num2str(data{pos(1),pos(2)},4)]};
% 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 ----------- Thanks
回答(1 个)
michael fried
2020-2-12
You'll have to first display the data-tip for some plot before saving the fig, then it shouldn't disappear.
Displaying a data-tip programmatically is explained by Yair Altman here: controlling-plot-data-tips
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!