Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous contents
Next: Programming Constructs Up: Matlab Databook Previous: Movies

Graphics and Objects

Though it's not essential to know how matlab graphics are organised, it's likely to be useful sooner or later.

Figures are made of objects (lines, text, images etc). Objects have properties (like Color, Position, etc) which can be individually controlled. Each object has a handle (a unique identifier). To experiment with handles, create a simple graph by typing `plot(1:3)'. Typing `gcf' returns the handle of the current figure. `get(handle)' lists the properties of the given object, so get(gcf) lists all the properties of the current figure. You can use set to change the values of these properties once you know the handle of the object and name of the property. For example, to set the foreground color of the current figure to green, use set(gcf,'Color','green'). If you type set(gcf) you get a list of the properties of the current figure, and alternative settings for these properties.

The axes are children of the figure - and consequently inherit some of the figure's properties. If you type get(gcf,'Children') you'll get the axes handle, which you could also get by typing `gca'. The axes in turn can have children.

`set' is a powerful mechanism. Often matlab has commands that spare you needing to use set directly, but particularly if you want to retrospectively fix something, the facility is useful.


next up previous contents
Next: Programming Constructs Up: Matlab Databook Previous: Movies
© Cambridge University Engineering Dept
Information provided by Tim Love
2006-07-24