source: MML/trunk/applications/doc_html/applications/common/suptitle.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: 7.7 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 suptitle</title>
6  <meta name="keywords" content="suptitle">
7  <meta name="description" content="SUPTITLE -Puts a title above all subplots.">
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; suptitle.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>suptitle
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>SUPTITLE -Puts a title above all subplots.</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 hout=suptitle(str) </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">SUPTITLE -Puts a title above all subplots.
31 suptitle('text') adds text to the top of the figure
32 above all subplots (a &quot;super title&quot;). Use this function
33 after all subplot commands.</pre></div>
34
35<!-- crossreference -->
36<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
37This function calls:
38<ul style="list-style-image:url(../../matlabicon.gif)">
39</ul>
40This function is called by:
41<ul style="list-style-image:url(../../matlabicon.gif)">
42</ul>
43<!-- crossreference -->
44
45
46<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
47<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function hout=suptitle(str)</a>
480002 <span class="comment">%SUPTITLE -Puts a title above all subplots.</span>
490003 <span class="comment">% suptitle('text') adds text to the top of the figure</span>
500004 <span class="comment">% above all subplots (a &quot;super title&quot;). Use this function</span>
510005 <span class="comment">% after all subplot commands.</span>
520006
530007 <span class="comment">% Drea Thomas 6/15/95 drea@mathworks.com</span>
540008
550009 <span class="comment">% John Cristion 12/13/00 modified</span>
560010
570011 <span class="comment">% Warning: If the figure or axis units are non-default, this</span>
580012 <span class="comment">% will break.</span>
590013
600014
610015
620016 <span class="comment">% This will disable sub- and super-scripts (JAC)</span>
630017
640018 set(0,<span class="string">'DefaultTextInterpreter'</span>,<span class="string">'none'</span>);
650019
660020 <span class="comment">% Parameters used to position the supertitle.</span>
670021
680022 <span class="comment">% Amount of the figure window devoted to subplots</span>
690023 plotregion = .92;
700024
710025 <span class="comment">% Y position of title in normalized coordinates</span>
720026 titleypos  = .95;
730027
740028 <span class="comment">% Fontsize for supertitle</span>
750029 <span class="comment">%fs = get(gcf,'defaultaxesfontsize')+4;</span>
760030
770031 fs = get(gcf,<span class="string">'defaultaxesfontsize'</span>);
780032
790033 <span class="comment">% Fudge factor to adjust y spacing between subplots</span>
800034 fudge=1;
810035
820036 haold = gca;
830037 figunits = get(gcf,<span class="string">'units'</span>);
840038
850039 <span class="comment">% Get the (approximate) difference between full height (plot + title</span>
860040 <span class="comment">% + xlabel) and bounding rectangle.</span>
870041
880042  <span class="keyword">if</span> (~strcmp(figunits,<span class="string">'pixels'</span>)),
890043   set(gcf,<span class="string">'units'</span>,<span class="string">'pixels'</span>);
900044   pos = get(gcf,<span class="string">'position'</span>);
910045   set(gcf,<span class="string">'units'</span>,figunits);
920046  <span class="keyword">else</span>,
930047   pos = get(gcf,<span class="string">'position'</span>);
940048  <span class="keyword">end</span>
950049  ff = (fs-4)*1.27*5/pos(4)*fudge;
960050
970051         <span class="comment">% The 5 here reflects about 3 characters of height below</span>
980052         <span class="comment">% an axis and 2 above. 1.27 is pixels per point.</span>
990053
1000054 <span class="comment">% Determine the bounding rectange for all the plots</span>
1010055
1020056 <span class="comment">% h = findobj('Type','axes');</span>
1030057
1040058 <span class="comment">% findobj is a 4.2 thing.. if you don't have 4.2 comment out</span>
1050059 <span class="comment">% the next line and uncomment the following block.</span>
1060060 
1070061 h = findobj(gcf,<span class="string">'Type'</span>,<span class="string">'axes'</span>);  <span class="comment">% Change suggested by Stacy J. Hills</span>
1080062
1090063 <span class="comment">% If you don't have 4.2, use this code instead</span>
1100064 <span class="comment">%ch = get(gcf,'children');</span>
1110065 <span class="comment">%h=[];</span>
1120066 <span class="comment">%for i=1:length(ch),</span>
1130067 <span class="comment">%  if strcmp(get(ch(i),'type'),'axes'),</span>
1140068 <span class="comment">%    h=[h,ch(i)];</span>
1150069 <span class="comment">%  end</span>
1160070 <span class="comment">%end</span>
1170071
1180072 
1190073
1200074
1210075 max_y=0;
1220076 min_y=1;
1230077
1240078 oldtitle =0;
1250079 <span class="keyword">for</span> i=1:length(h),
1260080  <span class="keyword">if</span> (~strcmp(get(h(i),<span class="string">'Tag'</span>),<span class="string">'suptitle'</span>)),
1270081   pos=get(h(i),<span class="string">'pos'</span>);
1280082   <span class="keyword">if</span> (pos(2) &lt; min_y), min_y=pos(2)-ff/5*3;<span class="keyword">end</span>;
1290083   <span class="keyword">if</span> (pos(4)+pos(2) &gt; max_y), max_y=pos(4)+pos(2)+ff/5*2;<span class="keyword">end</span>;
1300084  <span class="keyword">else</span>,
1310085   oldtitle = h(i);
1320086  <span class="keyword">end</span>
1330087 <span class="keyword">end</span>
1340088
1350089 <span class="keyword">if</span> max_y &gt; plotregion,
1360090  scale = (plotregion-min_y)/(max_y-min_y);
1370091  <span class="keyword">for</span> i=1:length(h),
1380092   pos = get(h(i),<span class="string">'position'</span>);
1390093   pos(2) = (pos(2)-min_y)*scale+min_y;
1400094   pos(4) = pos(4)*scale-(1-scale)*ff/5*3;
1410095   set(h(i),<span class="string">'position'</span>,pos);
1420096  <span class="keyword">end</span>
1430097 <span class="keyword">end</span>
1440098
1450099 np = get(gcf,<span class="string">'nextplot'</span>);
1460100 set(gcf,<span class="string">'nextplot'</span>,<span class="string">'add'</span>);
1470101 <span class="keyword">if</span> (oldtitle),
1480102  delete(oldtitle);
1490103 <span class="keyword">end</span>
1500104 ha=axes(<span class="string">'pos'</span>,[0 1 1 1],<span class="string">'visible'</span>,<span class="string">'off'</span>,<span class="string">'Tag'</span>,<span class="string">'suptitle'</span>);
1510105 ht=text(.5,titleypos-1,str);set(ht,<span class="string">'horizontalalignment'</span>,<span class="string">'center'</span>,<span class="string">'fontsize'</span>,fs);
1520106 set(gcf,<span class="string">'nextplot'</span>,np);
1530107 axes(haold);
1540108 <span class="keyword">if</span> nargout,
1550109  hout=ht;
1560110 <span class="keyword">end</span></pre></div>
157<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>
158</body>
159</html>
Note: See TracBrowser for help on using the repository browser.