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 17:10:02 +0000 (UTC)
Organization: Georgia Institute of Technology
Lines: 10
Message-ID: <h3vk1a$c1n$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> <h3v8t2$rl$1@fred.mathworks.com> <h3vbuh$jle$1@fred.mathworks.com> <h3veu5$739$1@fred.mathworks.com> <h3vh79$91s$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1248023402 12343 172.30.248.35 (19 Jul 2009 17:10:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 19 Jul 2009 17:10:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 939004
Xref: news.mathworks.com comp.soft-sys.matlab:556641


"Ben " <breedlun@hotmail.com> wrote in message 
> Thanks, Matt, for your reply.  I think you may be right.  Extent only gives me values rounded to 0.2 (position can give me more precise values).  My get(0,'screenpixelsperinch')=90, so one point is 5/4 pixels.  Extent seems to give correct locations for the extent box when grid_spacing is any multiple of 4.  And 24 happens to be a multiple of 4 and 3, which is why your analysis worked out too.
> 
> The problem I'm trying to solve here is a rather ridiculous one.  In a plot, my advisor absolutely requires roman letters to be 18 pt helvetica font and greek letters to be 21 pt symbol font.  He also wants the subscripts in a specific location relative to the base variable.  The only way I can figure out how to do this in Matlab is to explicitly place the subscript, rather than use LaTeX or TeX.  To place the subscript accurately I need to know the location and size of the base variable, which is why I was trying to use the extent property.  Once I'm done creating a plot, I export it to pdf, and sometimes blow it up to put in posters and presentations.  In these cases, having sub-pixel resolution becomes important.  It's insane, I know, but my advisor is rather draconian about the appearance of plots.


Ah, I suppose that's as good a reason as any.

On further investigation, I think it's a little different that I said above. The rounding is actually to (in your case) 72/90 = 0.8 (all your extents are multiples of 0.8). In my case the rounding is to 0.75 because i have 96 dpi. Apparently MATLAB calculates all positions/extents in integer values of pixels, so when you ask for the extent in points, it just calculates it rounded to the nearest pixel, and then converts to points by multiplying by 72/90. I suppose this means you can't actually specify a precision to a fraction of a pixel, so if you need more precision you'll need to actually make your figure larger on the screen so it has more pixels to work with. You might be able to set up your figure, then set all units to "normalized" using set(get(gcf,'children'),'units','normalized) then scale up the figure and everything inside should scale up accordingly. Maybe then you can make 
minor adjustments where you need to before you export.