1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
Usage
This function divides the current figure into a 2-
dimensional grid, each of which can contain a plot of some
kind. The function has a number of syntaxes. The first
version
subplot(row,col,num)
which either activates subplot number num, or sets up a
subplot grid of size row x col, and then activates num. You
can also set up subplots that cover multiple grid elements
subplot(row,col,[vec])
where vec is a set of indexes covered by the new subplot.
Finally, as a shortcut, you can specify a string with three
components
subplot('mnp')
or using the alternate notation
subplot mnp
where m is the number of rows, n is the number of columns
and p is the index. You can also specify the location of the
subplot explicitly using the syntax
subplot('position',[left bottom width height])
Example
Here is the use of subplot to set up a 2 x 2 grid of plots
--> t = linspace(-pi,pi);
--> subplot(2,2,1)
--> plot(t,cos(t).*exp(-2*t));
--> subplot(2,2,2);
--> plot(t,cos(t*2).*exp(-2*t));
--> subplot(2,2,3);
--> plot(t,cos(t*3).*exp(-2*t));
--> subplot(2,2,4);
--> plot(t,cos(t*4).*exp(-2*t));
subplot1.png
Here we use the second form of subplot to generate one
subplot that is twice as large.
--> t = linspace(-pi,pi);
--> subplot(2,2,[1,2])
--> plot(t,cos(t).*exp(-2*t));
--> subplot(2,2,3);
--> plot(t,cos(t*3).*exp(-2*t));
--> subplot(2,2,4);
--> plot(t,cos(t*4).*exp(-2*t));
subplot2.png
Note that the subplots can contain any handle graphics
objects, not only simple plots.
--> t=0:(2*pi/100):(2*pi);
--> x=cos(t*2).*(2+sin(t*3)*.3);
--> y=sin(t*2).*(2+sin(t*3)*.3);
--> z=cos(t*3)*.3;
--> subplot(2,2,1)
--> plot(t,x);
--> subplot(2,2,2);
--> plot(t,y);
--> subplot(2,2,3);
--> plot(t,z);
--> subplot(2,2,4);
--> tubeplot(x,y,z,0.14*sin(t*5)+.29,t,10)
--> axis equal
--> view(3)
subplot3.png
* FreeMat_Documentation
* Handle-Based_Graphics
* Generated on Thu Jul 25 2013 17:17:26 for FreeMat by
doxygen_ 1.8.1.1
|