I have recently tried to run an old piece of code (written on hg1) on a new version of MATLAB (2015a) that has hg2.
I used to be able to do the following (according to the "gnovice-Amro" method):
function output_txt = customDatatip(~,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).
hFig = ancestor(event_obj.Target,'figure'); %// I don't trust gcf ;)
pos = get(event_obj,'Position');
output_txt = {['\lambda: ',num2str(pos(1)*1000,4) 'nm'],...
['T(\lambda): ',num2str(pos(2),4) '%']};
set(findall(hFig, 'Type','text', 'Tag','DataTipMarker'),...
'Interpreter','tex'); %// Change the interpreter
And would get nicely formatted datatip labels with Greek characters.
However, in the new hg2 system, findall returns a 0x0 empty GraphicsPlaceholder array, which renders setting the Interpreter useless.
My question is: How can I set the plot datatip interpreter to (La)TeX in hg2?
After some digging using
uiinspect, I found that the"TextBox"is now stored as amatlab.graphics.shape.internal.GraphicsTiptype of object withinobj'sTipHandleproperty which, in turn, has anInterpreterproperty! Both properties arepublicand can be set easily using dot notation. I've ended up using the following code:Notes:
obj) is no longer ignored, since it has some use now.ishg2function is taken from this MATLAB Answer.Edit1:
Just noticed that there's another way to check MATLAB's Graphic version (i.e. hg1/hg2) using the following code I found in the wavelet toolbox: