source: MML/trunk/applications/doc_html/applications/common/zoomfixticks.html @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 11.2 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2                "http://www.w3.org/TR/REC-html40/loose.dtd">
3<html>
4<head>
5  <title>Description of zoomfixticks</title>
6  <meta name="keywords" content="zoomfixticks">
7  <meta name="description" content="ZOOMFIXTICKS - Allows zoom to work on a figure whose AXES tick labels are manually set">
8  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
9  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
10  <meta name="robots" content="index, follow">
11  <link type="text/css" rel="stylesheet" href="../../m2html.css">
12</head>
13<body>
14<a name="_top"></a>
15<div><a href="../../index.html">Home</a> &gt;  <a href="#">applications</a> &gt; <a href="index.html">common</a> &gt; zoomfixticks.m</div>
16
17<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
18<td align="right"><a href="index.html">Index for applications/common&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->
19
20<h1>zoomfixticks
21</h1>
22
23<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
24<div class="box"><strong>ZOOMFIXTICKS - Allows zoom to work on a figure whose AXES tick labels are manually set</strong></div>
25
26<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
27<div class="box"><strong>function zoomfixticks(fig,method,varargin) </strong></div>
28
29<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
30<div class="fragment"><pre class="comment">ZOOMFIXTICKS - Allows zoom to work on a figure whose AXES tick labels are manually set
31   ZOOMFIXTICKS(FIG) operates on the figure with handle FIG.
32   ZOOMFIXTICKS(AX) operates on the figure with child AXES handle AX.
33   ZOOMFIXTICKS with no arguments operates on the current figure.
34
35   Note that when using this function, you will need to modify the FIXTICKS
36   subfunction to meet your application needs.  Alternatively, you can comment
37   out the function and supply it as an M-file function on the MATLAB path. 
38   If you supply your own, make sure that the M-file is named &quot;fixticks.m&quot;, and
39   it takes a single input argument, the handle to an AXES object.
40
41   Example:
42       hf = figure;
43       xdata = [0:.01:1];
44       ydata = 100000*sin(2*pi*5*xdata);
45       plot(xdata,ydata);
46       zoomfixticks(hf)
47
48   Greg Aloe (8-8-2002)</pre></div>
49
50<!-- crossreference -->
51<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
52This function calls:
53<ul style="list-style-image:url(../../matlabicon.gif)">
54</ul>
55This function is called by:
56<ul style="list-style-image:url(../../matlabicon.gif)">
57</ul>
58<!-- crossreference -->
59
60<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
61<ul style="list-style-image:url(../../matlabicon.gif)">
62<li><a href="#_sub1" class="code">function init(fig)</a></li><li><a href="#_sub2" class="code">function zoomInCallback(hcbo,fig)</a></li><li><a href="#_sub3" class="code">function zoomOutCallback(hcbo,fig)</a></li><li><a href="#_sub4" class="code">function downFcn(fig)</a></li><li><a href="#_sub5" class="code">function fixticks(ax)</a></li></ul>
63<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
64<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function zoomfixticks(fig,method,varargin)</a>
650002 <span class="comment">%ZOOMFIXTICKS - Allows zoom to work on a figure whose AXES tick labels are manually set</span>
660003 <span class="comment">%   ZOOMFIXTICKS(FIG) operates on the figure with handle FIG.</span>
670004 <span class="comment">%   ZOOMFIXTICKS(AX) operates on the figure with child AXES handle AX.</span>
680005 <span class="comment">%   ZOOMFIXTICKS with no arguments operates on the current figure.</span>
690006 <span class="comment">%</span>
700007 <span class="comment">%   Note that when using this function, you will need to modify the FIXTICKS</span>
710008 <span class="comment">%   subfunction to meet your application needs.  Alternatively, you can comment</span>
720009 <span class="comment">%   out the function and supply it as an M-file function on the MATLAB path.</span>
730010 <span class="comment">%   If you supply your own, make sure that the M-file is named &quot;fixticks.m&quot;, and</span>
740011 <span class="comment">%   it takes a single input argument, the handle to an AXES object.</span>
750012 <span class="comment">%</span>
760013 <span class="comment">%   Example:</span>
770014 <span class="comment">%       hf = figure;</span>
780015 <span class="comment">%       xdata = [0:.01:1];</span>
790016 <span class="comment">%       ydata = 100000*sin(2*pi*5*xdata);</span>
800017 <span class="comment">%       plot(xdata,ydata);</span>
810018 <span class="comment">%       zoomfixticks(hf)</span>
820019 <span class="comment">%</span>
830020 <span class="comment">%   Greg Aloe (8-8-2002)</span>
840021
850022
860023 <span class="comment">% Set up the figure if there are less than 2 arguments</span>
870024 <span class="keyword">if</span> nargin &lt; 2
880025     <span class="comment">% Make sure the input is a handle to an AXES or FIGURE</span>
890026     <span class="keyword">if</span> nargin==0
900027         <span class="comment">% If no arguments, assume the current figure</span>
910028         fig = gcf;
920029     <span class="keyword">elseif</span> ishandle(fig) &amp; ~strcmp(lower(get(fig,<span class="string">'type'</span>)),<span class="string">'figure'</span>)
930030         <span class="comment">% If FIG is a handle, but not to a figure, assume it's an axes and get its parent</span>
940031         fig = get(fig,<span class="string">'parent'</span>);
950032     <span class="keyword">end</span>
960033
970034     <span class="comment">% Error out if the input is not a handle, or not a handle to a figure or axes</span>
980035     <span class="keyword">if</span> ~ishandle(fig) | (ishandle(fig) &amp; ~strcmp(lower(get(fig,<span class="string">'type'</span>)),<span class="string">'figure'</span>))
990036         error(<span class="string">'Input argument must be a handle to an AXES or FIGURE object.'</span>)
1000037     <span class="keyword">end</span>
1010038     
1020039     <span class="comment">% Initialize the setup of the figure</span>
1030040     <a href="#_sub1" class="code" title="subfunction init(fig)">init</a>(fig)
1040041 <span class="keyword">else</span>
1050042     <span class="comment">% if 2 or more arguments, perform the desired operation</span>
1060043     feval(method,varargin{:})
1070044 <span class="keyword">end</span>
1080045     
1090046
1100047 <span class="comment">%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
1110048 <a name="_sub1" href="#_subfunctions" class="code">function init(fig)</a>
1120049 <span class="comment">% This function sets up the figure so that zooms will work even when the AXES</span>
1130050 <span class="comment">% ticklabels are set manually</span>
1140051 
1150052 <span class="comment">% Change the callback for the &quot;Zoom In&quot; toolbar button</span>
1160053 hin = findall(fig,<span class="string">'tag'</span>,<span class="string">'figToolZoomIn'</span>);
1170054 set(hin,<span class="string">'ClickedCallback'</span>,<span class="string">'zoomfixticks(gcbf,''zoomInCallback'',gcbo,gcbf)'</span>)
1180055
1190056 <span class="comment">% Change the callback for the &quot;Zoom Out&quot; toolbar button</span>
1200057 hout = findall(fig,<span class="string">'tag'</span>,<span class="string">'figToolZoomOut'</span>);
1210058 set(hout,<span class="string">'ClickedCallback'</span>,<span class="string">'zoomfixticks(gcbf,''zoomOutCallback'',gcbo,gcbf)'</span>)
1220059
1230060 <span class="comment">% Fix the ticks on initialization</span>
1240061 <a href="#_sub5" class="code" title="subfunction fixticks(ax)">fixticks</a>(gca(fig))
1250062
1260063 <span class="comment">%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
1270064 <a name="_sub2" href="#_subfunctions" class="code">function zoomInCallback(hcbo,fig)</a>
1280065 <span class="comment">% Callback for the &quot;Zoom In&quot; button</span>
1290066
1300067 <span class="comment">% First call what is normally called during a zoom in</span>
1310068 putdowntext(<span class="string">'zoomin'</span>,hcbo)
1320069
1330070 <span class="comment">% If the button is depressed, force WindowButtonDownFcn to call the DOWNFCN subfunction</span>
1340071 <span class="keyword">if</span> strcmp(get(hcbo,<span class="string">'state'</span>),<span class="string">'on'</span>)
1350072     set(fig,<span class="string">'WindowButtonDownFcn'</span>,<span class="string">'zoomfixticks(gcbf,''downFcn'',gcbf)'</span>)
1360073 <span class="keyword">end</span>
1370074
1380075
1390076 <span class="comment">%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
1400077 <a name="_sub3" href="#_subfunctions" class="code">function zoomOutCallback(hcbo,fig)</a>
1410078 <span class="comment">% Callback for the &quot;Zoom Out&quot; button</span>
1420079
1430080 <span class="comment">% First call what is normally called during a zoom out</span>
1440081 putdowntext(<span class="string">'zoomout'</span>,hcbo)
1450082
1460083 <span class="comment">% If the button is depressed, force WindowButtonDownFcn to call the DOWNFCN subfunction</span>
1470084 <span class="keyword">if</span> strcmp(get(hcbo,<span class="string">'state'</span>),<span class="string">'on'</span>)
1480085     set(fig,<span class="string">'WindowButtonDownFcn'</span>,<span class="string">'zoomfixticks(gcbf,''downFcn'',gcbf)'</span>)
1490086 <span class="keyword">end</span>
1500087
1510088
1520089 <span class="comment">%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
1530090 <a name="_sub4" href="#_subfunctions" class="code">function downFcn(fig)</a>
1540091 <span class="comment">% Since the button was pressed, tell the figure that we are starting a zoom</span>
1550092 zoom(fig,<span class="string">'down'</span>);
1560093
1570094 <span class="comment">% After the zoom, fix the ticks</span>
1580095 <a href="#_sub5" class="code" title="subfunction fixticks(ax)">fixticks</a>(gca(fig))
1590096
1600097
1610098 <span class="comment">%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span>
1620099 <a name="_sub5" href="#_subfunctions" class="code">function fixticks(ax)</a>
1630100 <span class="comment">% This function will perform the desired ticklabel fixing</span>
1640101 <span class="comment">% This is the function you will want to modify to meet your application needs</span>
1650102 <span class="comment">% Alternatively, you can comment out this function to call an M-file function</span>
1660103 <span class="comment">% in its place.</span>
1670104
1680105 <span class="comment">% EXAMPLE:</span>
1690106 <span class="comment">% First update the axes so the ticks are as expected</span>
1700107 drawnow
1710108 <span class="comment">% Get the ticks</span>
1720109 tick=get(ax,<span class="string">'ytick'</span>);
1730110 <span class="comment">% Convert ticks to a string of the desired format</span>
1740111 tickstr=num2str(tick',7);
1750112 <span class="comment">% Reset the labels to the new format</span>
1760113 set(ax,<span class="string">'yticklabel'</span>,tickstr);</pre></div>
177<hr><address>Generated on Mon 21-May-2007 15:32:41 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
178</body>
179</html>
Note: See TracBrowser for help on using the repository browser.