Creating Graphical User Interfaces Previous page   Next Page

Axes

Axes enable your GUI to display graphics (e.g., graphs and images). Like all graphics objects, axes have properties that you can set to control many aspects of its behavior and appearance. See Axes Properties" in the MATLAB Graphics documentation for general information on axes objects.

Axes Callbacks

Axes are not uicontrol objects, but can be programmed to execute a callback when users click a mouse button in the axes. Use the axes ButtonDownFcn property to define the callback.

Plotting to Axes in GUIs

If your GUI contains axes, you should make sure that the Command-line accessibility option in the GUI Options dialog is set to Callback (the default). This enables you to issue plotting commands from callbacks without explicitly specifying the target axes. See Command-Line Accessibility for more information about how this option works.

Example: Displaying an Image on an Axes

This example shows how to display an image on an axes. The example

To build the example:

  1. Open a blank template in the Layout Editor.
  2. Drag an axes into the layout area.
  3. Select M-file editor from the View menu.
  4. Add the following code to the opening function:

When you run the GUI, it appears as in the following figure.

MATLAB demos

The preceding code performs the following operations:

GUIs with Multiple Axes

If a GUI has multiple axes, you should explicitly specify which axes you want to target when you issue plotting commands. You can do this using the axes command and the handles structure. For example,

makes the axes whose Tag property is axes1 the current axes, and therefore the target for plotting commands. You can switch the current axes whenever you want to target a different axes. See GUI with Multiple Axes for an example that uses two axes.


Previous page  Button Groups ActiveX Controls Next page

© 1994-2005 The MathWorks, Inc.