Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Text property, 'extent', not working properly
Date: Sat, 18 Jul 2009 19:58:01 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 49
Message-ID: <h3t9g9$fe2$1@fred.mathworks.com>
References: <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 1247947081 15810 172.30.248.38 (18 Jul 2009 19:58:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 18 Jul 2009 19:58:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:556523


"Ben " <breedlun@hotmail.com> wrote in message <h3slb9$nsa$1@fred.mathworks.com>...
> 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.

as usual: it is not a ML bug...
rather, you're snippet does not set the axis-lims correctly...

one of the solutions

% the data
     cs=24;
     f=[450,450];
% the engine
     grid_spacing=cs;
     fh=figure;
     set(fh,...
          'units','points',...
          'position',[500,100,f(1),f(2)]);
     fig_ax=axes(...
          'units','points',...
          'position',[0,0,f(1),f(2)],...
          'xlim',[0,f(1)],...     % <- set XLIM!
          'ylim',[0,f(2)],...     % <- set YLIM!
          'visible','off');
for  i=1:4
     ypos=450-i*grid_spacing;
for  j=1:4
     xpos=j*grid_spacing;
     label=text(xpos,ypos,'\delta',...
          'units','data',...
          'interpreter','tex',...
          'horizontalalignment','left',...
          'verticalalignment','bottom',...
          'fontsize',18,...
          'fontname','helvetica',...
          'backgroundcolor',[1,1,0]);
     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);
     line([x_pos(i,j),x_pos(i,j)],[0,f(2)],...
          'color',[1,0,0]);
     line([x_ext(i,j),x_ext(i,j)],[0,f(2)],...
          'color',[0,1,0]);
end
end

us