Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Text property, 'extent', not working properly
Date: Sat, 18 Jul 2009 14:14:01 +0000 (UTC)
Organization: Univeristy of Michigan
Lines: 51
Message-ID: <h3slb9$nsa$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1247926441 24458 172.30.248.38 (18 Jul 2009 14:14:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 18 Jul 2009 14:14:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1397212
Xref: news.mathworks.com comp.soft-sys.matlab:556494


It appears that the text property 'extent' does not correctly report the position of the text extent box, unless the position is a multiple of 4.  The position it reports is close, which is probably why I can't find anyone else who has noticed this, but it is clearly wrong as demonstrated by the following script.

________________________________________________________________________
figure;
f=[450,450];
set(gcf,'Units','points','position',[0,0,f(1),f(2)])
fig_ax=axes('Units','points','Position',[0 0 f(1) f(2)],'Visible','off');
axis([0 f(1) 0 f(2)]);
grid_spacing=25;
for i=1:4
    for j=1:4
        label=text(j*grid_spacing,450-i*grid_spacing,'\delta','FontSize',18,...
            'HorizontalAlignment','left','Interpreter','tex',...
            'VerticalAlignment','bottom','FontName','Helvetica','units','points');
        %Print subscript if specified
        label_ext=get(label,'extent');
        label_pos=get(label,'position');
        x_ext(i,j)=label_ext(1);
        x_pos(i,j)=label_pos(1);
        y_ext(i,j)=label_ext(2);
        y_pos(i,j)=label_pos(2);
    end
end
_______________________________________________________________________
The output variables x_ext, x_pos, y_ext, and y_pos give the position of the text box. Here are those 4 outputs, for the grid spacing of 25:

x_ext =
   24.8000   50.4000   75.2000  100.0000
   24.8000   50.4000   75.2000  100.0000
   24.8000   50.4000   75.2000  100.0000
   24.8000   50.4000   75.2000  100.0000

x_pos =
    25    50    75   100
    25    50    75   100
    25    50    75   100
    25    50    75   100

y_ext =
  423.2000  423.2000  423.2000  423.2000
  398.4000  398.4000  398.4000  398.4000
  373.6000  373.6000  373.6000  373.6000
  348.0000  348.0000  348.0000  348.0000

y_pos =
   425   425   425   425
   400   400   400   400
   375   375   375   375
   350   350   350   350

As you can see, the spacing of 25 is correctly reported by x_pos and y_pos, but incorrectly reported by x_ext, and y_ext.  If the grid spacing is set to 24 (a multiple of 4), the outputs x_ext and y_ext are correct.  Well, hopefully I'm doing something wrong, or MathWorks will see this and correct the bug.