Code covered by the BSD License  

Highlights from
TextZoomable for text that scales as you zoom

4.5

4.5 | 5 ratings Rate this file 11 Downloads (last 30 days) File Size: 2.22 KB File ID: #41513
image thumbnail

TextZoomable for text that scales as you zoom

by

 

Text that zooms as you zoom your plot, rather than staying at a fixed font size.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

Text that zooms as you zoom your plot, rather than staying at a fixed font size. Adds text to a figure just like the text() command, except that this text grows/shrinks with figure scaling and zooming, unlike normal text that stays at a fixed font size during figure operations. Note it scales with figure height - for best scaling use 'axis equal' before setting up the text.

MATLAB release MATLAB 8.1 (R2013a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
27 Mar 2014 Matt J

Here's a better version of the DeleteFcn,

function DeleteMethod(src,event)
% when called, rescale all fonts in image
hAx=gca;
hFig = get(hAx,'Parent');
ud=get(hAx, 'UserData');
idx=(ud.handles==src);

ud.ratios(idx)=[];
ud.handles(idx)=[];



if isempty(ud.handles)
setappdata(hFig,'KenAxeResizeListeners',[]);
set(hAx, 'UserData',[]);
else
set(hAx, 'UserData',ud);
end

delete(src);

end

27 Mar 2014 Matt J

Ken,

There seems to be a duplicate of this submission at

http://www.mathworks.com/matlabcentral/fileexchange/41501-textzoomable-for-text-that-scales-as-you-zoom

Which is the most official/current version? Also, when I do a very high zoom on the text, parts of the text appear outside the axes. Is there a way to prevent this, i.e., so that only text within the window of the axes is visible?

27 Mar 2014 Matt J

I get the same errors/warnings as Nispio, but setting txtHandle's DeleteFcn callback to the following seems to fix it.

function DeleteMethod(src,event)
% when called, rescale all fonts in image
hAxes=gca;
hFig = get(hAxes,'Parent');
setappdata(hFig,'KenAxeResizeListeners',[]);
set(hAxes, 'UserData',[]);
delete(src);
end

04 Nov 2013 Nispio

This gives the following warnings/errors whenever I try to plot over the top of my old plot.

Warning: Error occurred while evaluating listener callback.
> In axis>LocSetTight1 at 332
In axis>LocSetTight at 277
In axis>LocSetImage at 414
In axis at 135
In showimage at 5
Attempt to reference field of non-structure array.

Error in TextZoomable>getBestFontSize (line 70)
fs = round(ud.ratios * hFigFactor / axHeight);

Error in TextZoomable>localLimitListener (line 106)
fs = getBestFontSize(imAxes);

04 Nov 2013 Nispio  
18 Oct 2013 Krishnakumar  
07 Jun 2013 Simon  

Contact us