Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I find an annotation handle in MATLAB?
    primarykey
    data
    text
    <p>I'm trying to implement a modified version of <a href="http://www.mathworks.com/matlabcentral/fileexchange/20422-datetick-with-zooming-panning-and-subplots" rel="noreferrer">datetick2</a> 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. </p> <p>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, <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/findobj.html" rel="noreferrer">findobj</a> doesn't seem to work for the hggroup type, which is what annotations fall under. Am I using it wrong?</p> <p>Here's a code example:</p> <pre><code>&gt;&gt; times=now-[50:-5:0]; &gt;&gt; days=times-times(1); &gt;&gt; plot(times,days) &gt;&gt; datetick2() &gt;&gt; xlabel('Date') &gt;&gt; ylabel('Days') &gt;&gt; title('Example') &gt;&gt; initialdate=datestr(min(get(gca,'xlim')),'dd-mmm-yyyy'); &gt;&gt; txt=annotation('textbox', [.01,.01,.1,.05],... 'string', initialdate,... 'Linestyle','none'); &gt;&gt; &gt;&gt; &gt;&gt; findobj('type','hggroup') ans = Empty matrix: 0-by-1 &gt;&gt; get(txt,'type') ans = hggroup &gt;&gt; findobj('type','axes') ans = 270.0034 </code></pre> <p>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 <code>hggroup</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload