File: subplot.mdc

package info (click to toggle)
freemat 4.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 141,800 kB
  • ctags: 14,082
  • sloc: ansic: 126,788; cpp: 62,046; python: 2,080; perl: 1,255; sh: 1,146; yacc: 1,019; lex: 239; makefile: 100
file content (86 lines) | stat: -rw-r--r-- 2,030 bytes parent folder | download | duplicates (2)
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