Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Text property, 'extent', not working properly
Date: Sun, 19 Jul 2009 14:00:02 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 75
Message-ID: <h3v8t2$rl$1@fred.mathworks.com>
References: <h3slb9$nsa$1@fred.mathworks.com> <h3t9g9$fe2$1@fred.mathworks.com> <h3tt69$e99$1@fred.mathworks.com> <h3u041$lov$1@fred.mathworks.com> <h3v2ih$6h1$1@fred.mathworks.com> <h3v5pm$6sa$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 1248012002 885 172.30.248.38 (19 Jul 2009 14:00:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 19 Jul 2009 14:00:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:556600


"Ben " <breedlun@hotmail.com> wrote in message <h3v5pm$6sa$1@fred.mathworks.com>...
> "us " <us@neurol.unizh.ch> wrote in message <h3v2ih$6h1$1@fred.mathworks.com>...
> > % the look at the definition of EXTENT...
> > % in general, yet depending on the UNITs',
> > % the EXTENT is NOT equal to the POSITON
> 
> Yes, I understand this.  The extent is rarely equal to the position.  
> 
> I may have done a poor job of explaining my issue.  My claim is that the spacing between the text extent boxes should be the same as the grid spacing (cs).
> 
> I've changed my code to try to emphasize this:
> _______________________________________________________________________
> 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)],...
>     'xlim',[0,f(1)],'ylim',[0,f(2)],'Visible','off'); %<-Setting axis limits your way
> axis([0 f(1) 0 f(2)]); %<-This also sets the axis limits
> 
> grid_spacing=24;
> for i=1:2
>     for j=1:2
>         label=text(j*grid_spacing,450-i*grid_spacing,'f','FontSize',18,...
>             'HorizontalAlignment','center','Interpreter','tex',...
>             'VerticalAlignment','bottom','FontName','Helvetica','units','points');
>         label_ext=get(label,'extent');
>         x_ext(i,j)=label_ext(1);
>         y_ext(i,j)=label_ext(2);
>     end
> end
> dx=x_ext(:,2)-x_ext(:,1)
> dy=y_ext(1,:)-y_ext(2,:)
> _______________________________________________________________________
> 
> When grid_spacing=24, the output is:
> 
> dx =
>    24.0000
>    24.0000
> 
> dy =
>     24    24
> 
> This is correct.  The grid spacing matches the spacing between the text extent boxes.
> 
> However, when grid_spacing=25, the output is:
> 
> dx =
>    25.6000
>    25.6000
> 
> dy =
>    24.8000   24.8000
> 
> This, in my view, is incorrect.  The grid spacing does not match the spacing between the text extent boxes.
> 
> Well, hopefully I've been a little more clear now.

well, yes - and no...
1) did you use my snippet at all - including the LINEs, which (precisely) show you
    the POS and EXT of the background colored characters...
2) if you add these commands to your snippet: what do you see(?)...
3) now, what happens if you do this (make your snippet a bit more versatile...)
a) change your
     f=[450,450];
   to
     f=[450,250];
   and, thus, change
     label=text(j*grid_spacing,450-i*grid_spacing,'f','FontSize',18,...
   to
     label=text(j*grid_spacing,f(2)-i*grid_spacing,'f','FontSize',18,...
b) observe your Ds
c) now, since you're using PEL units, think about quantization...

us