Multiple Figures

Create a figure window bu calling figure

x = -10:0.1:10;

y1 = x.^2 - 8;

y2 = exp(x);

figure, plot(x, y1);

figure, plot(x, y2);

Be careful when using gcf handle(gca) while there exist multiple figures.

所以在这里弄清楚current axes和 current figure 还是十分有必要的.

Figure Position and Size

figure('position',[left,bottom,width, height]);

Several Plots in one Figure

Several small plots"in a figure"

subplot(m, n, 1);

其中的m referred to the number of rows

n referred to the number of columns


t = 0 : 0.1: 2*pi;

x = 3* cos(t);

y = sin(t);

subplot(2,2,1); plot(x,y) axis normal

subplot(2,2,2); plot(x,y) axis square

subplot(2,2,3); plot(x,y);axis equal

subplot(2,2,4); plot(x,y); axis equal tight

grid on/off

Make the grid visible or invisible

Make the box visible or invisible

axis on/off

Make the axes visible or invisible

axis normal

Automatically adjust the aspect ratio of the axes and the relative scaling of the data units

axis square

Make the current axis region square

Set the aspect ratio so that the data units are the same in every direction

axis equal tight

Set the axis limits to the range of the data.

Let the plot box fits tightly around the data

Place the origin of the corresponding system in the upper left corner

Place the origin in the lower left corner.


Saving Figures into Files


Option     Bitmap Image Format

'jpeg'        JPEG 24-bit

'png'          PNG 24-bit

'tiff"           TIFF 24-bit(compressed)

'bmpmono' BMP Monochrome

'bmp'         BMP 24-bit

'bmp256'   BMP 8-bit(256 color, used a fixed colormap)

'pdf'   Full page portable Document Format(PDF) color

'eps'     Encapsulated Postscript(EPS) Level 3 black and white

'epsc' Encapsulated Postscript(EPS) Level 3 color

'meta' Enhanced Metafile(Windows only)

'svg' (scalable vector graphics)

'ps' (Full-page postScript(PS) Level 3 black and white

'psc' Full-page Postscript(PS) Level 3 color

To control size and resolution,use print instead:

gcf 主要是写入位图和矢量图