I'm trying to implement a modified version of datetick2 from the MATLAB FEX. When plots are zoomed in on a small date range, the day/month/year, etc. isn't shown, depending on the range of times in the plot. I'd like to put a 'dd-mmm-yyyy' formatted starting date as an annotation in the bottom left corner of the figure. No problem, that's done.
However, next I want to have it update if the user selects a different date range with the zoom function. Instead of passing more handles, I want to just find the annotation. However, findobj doesn't seem to work for the hggroup type, which is what annotations fall under. Am I using it wrong?
Here's a code example:
>> times=now-[50:-5:0];
>> days=times-times(1);
>> plot(times,days)
>> datetick2()
>> xlabel('Date')
>> ylabel('Days')
>> title('Example')
>> initialdate=datestr(min(get(gca,'xlim')),'dd-mmm-yyyy');
>> txt=annotation('textbox', [.01,.01,.1,.05],...
'string', initialdate,...
'Linestyle','none');
>>
>>
>> findobj('type','hggroup')
ans =
Empty matrix: 0-by-1
>> get(txt,'type')
ans =
hggroup
>> findobj('type','axes')
ans =
270.0034
As you can see, findobj doesn't work, but if I use the handle I defined in the workspace, the type pops right out as hggroup
.