Anda di halaman 1dari 31

Matlab , Fall 2004

Lesson #7

Handle graphics
Graphics Objects Hierarchy.

There are about a dozen different kinds of graphics objects in MATLAB. root object corresponds to computer screen and it has no parent object. It exists after starting MATLAB program. It is parent of figure objects. Handle of rot object equals to zero. figure is parent of axes, uicontrols, uimenus and uicontextmenus. uicontrol and uimenu have no children. axes is parent of text, line, light, surface, patch, rectangle and image objects. Each object has an associated function that creates the object. These functions have the same name as the objects they create.

Matlab , Fall 2004

Lesson #7

Functions
This table lists commands commonly used when working with objects. Function Purpose copyobj Copy graphics object delete gca gcf gco get set More details: get Get object properties. V = get(H,'PropertyName') returns the value of the specified property for the graphics object with handle H. GET(H) displays all property names and their current values for the graphics object with handle H. Set object properties. set(H,'PropertyName',PropertyValue) sets the value of the specified property for the graphics object with handle H. H can be a vector of handles, in which case SET sets the properties values for all the objects. set(H,'PropertyName1', PropertyValue1, 'PropertyName2', PropertyValue2,...) sets multiple property values with a single statement. set(H,'PropertyName') displays the possible values for the specified property of the object with handle H. set(H) displays all property names and their possible values for the object with handle H. The default value for an object type can be set in an object's parent, grandparent, or great-grandparent by setting the PropertyName formed by concatenating the string 'Default', the object type, and the property name.
2

Delete an object Return the handle of the current axes Return the handle of the current figure Return the handle of the current object Query the value of an objects properties Set the value of an objects properties

findobj Find the handle of objects having specified property values

set

Matlab , Fall 2004

Lesson #7

For example, to set the default color of text objects to red in the current figure window:
set(gcf,'DefaultTextColor','red')

Three strings have special meaning for PropertyValues: 'default' 'factory' 'remove' reset use default value (from parents) use factory default value remove default value.

Reset axis or figure. reset(H) resets all properties, except position, of the object with handle H to their default values. For example, reset(gca) resets the properties of the current axis. reset(gcf) resets the properties of the current figure. Delete a file or graphics object. delete file_name deletes the named file from disk. delete(H) deletes the graphics object with handle H. If the object is a window, the window is closed and deleted without confirmation. Get current figure handle. H = gcf returns the handle to the current figure. The current figure is the figure (graphics window) that graphics commands like plot, title, surf, etc. draw to if issued. Use the commands figure to change the current figure to a different figure, or to create new ones. Get current axis handle. H = gca returns the handle to the current axis. The current axis is the axis that graphics commands like PLOT, TITLE, SURF, etc. draw to if issued. Use the commands axes or subplot to change the current axis to a different axis, or to create new ones. Mouse pointer can be used to change the current axis click on axes boundaries or labels. Create Figures (graph windows). figure, by itself, opens a new Figure (graph window), and returns an integer handle. figure(H) makes the H'th Figure the current Figure for subsequent plotting commands. If Figure H does not exist, a new one is created using the first available Figure handle. Create axis at arbitrary positions. axes('position', RECT) opens up an axis at the specified location and returns a handle to it. RECT = [left, bottom, width, height] specifies the location and size of the side of the axis box, relative to the lower-left corner of the Figure window, and in in normalized units where (0,0) is the lowerleft corner and (1.0,1.0) is the upper-right. axes, by itself, creates the default full-window axis and returns a handle to it. axes(H) makes the axis with handle H current.

delete

gcf

gca

figure

axes

Matlab , Fall 2004

Lesson #7

subplot

Create axes in tiled positions. subplot(m,n,p), or subplot(mnp), breaks the Figure window into an m-by-n matrix of small axes, selects the p-th axes for for the current plot, and returns the axis handle. The axes are counted along the top row of the Figure window, then the second row, etc. For example, subplot(2,1,1), plot(X,Y), subplot(2,1,2), plot(X,Z) plots Y on the top half of the window and Z on the bottom half. subplot(m,n,p), if the axis already exists, makes it current. subplot(H), where H is an axes handle, is another way of making an axis current for subsequent plotting commands. H=subplot() returns axes handle. If a subplot specification causes a new axis to overlap an existing axis, the existing axis is deleted. For example, the statement subplot(1,1,1) deletes all existing smaller axes in the Figure window and creates a new full-figure axis.

copyobj

Copy graphics objects and their descendants. new_handle = copyobj(h,p) copies one or more graphics objects identified by h and returns the handle of the new object or a vector of handles to new objects. The new graphics objects are children of the graphics objects specified by p. Locate graphics objects with specific properties. Usage: h = findobj('PropertyName',PropertyValue,...) h = findobj(objhandles, 'PropertyName',PropertyValue...) h = findobj(objhandles,'flat','PropertyName',PropertyValue,...) restricts the search to those objects listed in objhandles and does not search descendants. Example: Find all line objects in the current axes: h = findobj(gca,'type','line').

findobj

Matlab , Fall 2004

Lesson #7

Properties and Values of Graphics Objects

line objects
line creates a line object in the current axes. Usage: line(X,Y) adds the line defined in vectors X and Y to the current axes. If X and Y are matrices of the same size, line draws one line per column line(X,Y,Z) creates lines in three-dimensional coordinates. line(X,Y,Z,'PropertyName',PropertyValue,...) creates a line using the values for the property name/property value pairs specified and default values for all other properties. line('PropertyName',PropertyValue,...) creates a line in the current axes using the property values defined as arguments. This is the low-level form of the line function, which does not accept matrix coordinate data as the other informal forms described above. h = line(...) returns a column vector of handles corresponding to each line object the function creates. Property Name Data Defining the Object XData YData ZData The x-coordinates defining the line The y-coordinates defining the line The z-coordinates defining the line Values: vector or matrix Default: [0 1] Values: vector or matrix Default: [0 1] Values: vector or matrix Default: [] empty matrix Values: -, --, :, -., none Default: Values: scalar Default: 0.5 points Values: see Marker property
5

Property Description

Property Value

Defining Line Styles and Markers LineStyle LineWidth Marker Select from five line styles. The width of the line in points Marker symbol to plot at data points

Matlab , Fall 2004

Lesson #7

Default: none MarkerEdgeColor MarkerFaceColor MarkerSize Color of marker or the edge color for filled markers Fill color for markers that are closed shapes Size of marker in points Values: ColorSpec, none, auto Default: auto Values: ColorSpec, none, auto Default: none Values: size in points Default: 6 Values: on, off Default: on

Controlling the Appearance Clipping EraseMode Clipping to axes rectangle

Method of drawing and erasing the line (useful for animation) Values: normal, none, xor, background Default: normal

SelectionHighlight Highlight line when selected (Selected property set to on) Values: on, off Default: on Visible Color Make the line visible or invisible Color of the line Values: on, off Default: on ColorSpec

Controlling Access to Objects HandleVisibility HitTest Determines if and when the the line's handle is visible to other Values: on, callback, off functions Default: on Determines if the line can become the current object (see the figure CurrentObject property) Values: on, off Default: on

Matlab , Fall 2004

Lesson #7

General Information About the Line Children Parent Selected Tag Type UserData Line objects have no children The parent of a line object is always an axes object Indicate whether the line is in a "selected" state. User-specified label The type of graphics object (read only) User-specified data Values: [] (empty matrix) Value: axes handle Values: on, off Default: on Value: any string Default: '' (empty string) Value: the string 'line' Values: any matrix Default: [] (empty matrix) Values: cancel, queue Default: queue Values: string or function handle Default: '' (empty string) Values: string or function handle Default: '' (empty string) Values: string or function handle Default: '' (empty string) Values: on, off Default: on (can be interrupted) Values: handle of a Uicontextmenu

Properties Related to Callback Routine Execution BusyAction ButtonDownFcn CreateFcn DeleteFcn Interruptible UIContextMenu Specify how to handle callback routine interruption Define a callback routine that executes when a mouse button is pressed on over the line Define a callback routine that executes when a line is created Define a callback routine that executes when the line is deleted (via close or delete) Determine if callback routine can be interrupted Associate a context menu with the line

Matlab , Fall 2004

Lesson #7

text objects
text creates a text object in the current axes. Usage: text(x,y,'string') text(x,y,z,'string') text(...'PropertyName',PropertyValue...) h = text(...) text(x,y,z,'string','PropertyName',PropertyValue....) adds the string in quotes to location defined by the coordinates and uses the values for the specified text properties. See the text property list section at the end of this page for a list of text properties. Property Name Property Description Property Value

Defining the character string Editing Interpreter Enable or disable editing mode. Enable or disable TeX interpretation The character string (including list of TeX character sequences) Values: on, off Default: off Values: tex, none Default: tex Value: character string

String

Positioning the character string Extent Position and size of text object Values: [left, bottom, width, height] Values: left, center, right Default: left Values: [x, y, z] coordinates Default: [] empty matrix
8

HorizontalAlignment Horizontal alignment of text string Position Position of text Extent rectangle

Matlab , Fall 2004

Lesson #7

Rotation Units

Orientation of text object Units for Extent and Position properties

Values: scalar (degrees) Default: 0 Values: pixels, normalized, inches, centimeters, points, data Default: data Values: top, cap, middle, baseline, bottom Default: middle

VerticalAlignment

Vertical alignment of text string

Text Bounding Box BackgroundColor EdgeColor LineWidth LineStyle Margin Specifying the Font FontAngle Select italic-style font Values: normal, italic, oblique Default: normal Color of text extent rectangle Color of edge drawn around text extent rectangle Width of the line (in points) use to draw the box drawn around text extent rectangle Style of the line use to draw the box drawn around text extent rectangle Distance in pixels from the text extent to the edge of the box enclosing the text. Values: ColorSpec Default: none Values: ColorSpec Default: none Values: scalar (points) Default: 0.5 Values: -, --, :, -., none Default: Values: scalar (pixels) Default: 2

Matlab , Fall 2004

Lesson #7

FontName

Select font family

Values: a font supported by your system or the string FixedWidth Default: Helvetica Values: size in FontUnits Default: 10 points Values: points, normalized, inches, centimeters, pixels Default: points Values: light, normal, demi, bold Default: normal

FontSize

Size of font Units for FontSize property

FontUnits

FontWeight

Weight of text characters

Controlling the Appearance Clipping EraseMode SelectionHighlight Clipping to axes rectangle Method of drawing and erasing the text (useful for animation) Highlight text when selected (Selected property set to on) Make the text visible or invisible Color of the text Values: on, off Default: on Values: normal, none, xor, background Default: normal Values: on, off Default: on Values: on, off Default: on ColorSpec

Visible Color

10

Matlab , Fall 2004

Lesson #7

Controlling Access to Text Objects HandleVisibility Determines if and when the the text's handle is Values: on, callback, off visible to other functions Default: on Determines if the text can become the current Values: on, off object (see the figure CurrentObject Default: on property)

HitTest

General Information About Text Objects Children Parent Selected Text objects have no children The parent of a text object is always an axes object Indicate whether the text is in a "selected" state. User-specified label The type of graphics object (read only) User-specified data Values: [] (empty matrix) Value: axes handle Values: on, off Default: off Value: any string Default: '' (empty string) Value: the string 'text' Values: any matrix Default: [] (empty matrix)

Tag Type UserData

Controlling Callback Routine Execution BusyAction Specifies how to handle callback routine interruption Values: cancel, queue Default: queue

ButtonDownFcn

Defines a callback routine that executes when Values: string or function handle a mouse button is pressed on over the text Default: '' (empty string)
11

Matlab , Fall 2004

Lesson #7

CreateFcn DeleteFcn Interruptible

Defines a callback routine that executes when Values: string or function handle an text is created Default: '' (empty string) Defines a callback routine that executes when Values: string or function handle the text is deleted (via close or delete) Default: '' (empty string) Determines if callback routine can be interrupted Associates a context menu with the text Values: on, off Default: on (can be interrupted) Values: handle of a uicontextmenu

UIContextMenu

You can set default text properties on the axes, figure, and root levels.

set(0,'DefaulttextProperty',PropertyValue...) set(gcf,'DefaulttextProperty',PropertyValue...) set(gca,'DefaulttextProperty',PropertyValue...)

Note: Method of setting default properties as illustrated above applies to ALL graphics objects. Only word text is replaced with the proper name of corresponding graphics object. Example: set(0,'DefaultLineLineWidth',3) sets default width of all newly created lines to 3. Use set function to modify the default property values. Important: Read in addition MATLAB help for the objects listed below and try to remember names of important properties and default values. image surface patch light

12

Matlab , Fall 2004

Lesson #7

Axes
axes Create axes graphics object. Usage: axes creates an axes graphics object in the current figure using default property values. axes('PropertyName',PropertyValue,...) creates an axes object having the specified property values. MATLAB uses default values for any properties that you do not explicitly define as arguments. axes(h) makes existing axes h the current axes. It also makes h the first axes listed in the figure's Children property and sets the figure's CurrentAxes property to h. The current axes is the target for functions that draw image, line, patch, surface, and text graphics objects. h = axes(...) returns the handle of the created axes object. Property Description Toggle axes plot box on and off Line style used to draw axes grid lines Line style used to draw axes minor grid lines Property Value Values: on, off Default: off Values: -, --, :, -., none Default: : (dotted line) Values: -, --, :, -., none Default: : (dotted line)

Property Name Controlling Style and Appearance Box GridLineStyle MinorGridLineStyle Layer LineStyleOrder LineWidth SelectionHighlight TickDir

Draw axes above or below graphs Values: bottom, top Default: bottom Sequence of line styles used for multiline plots Width of axis lines, in points (1/72" per point) Highlight axes when selected (Selected property set to on) Direction of axis tick marks Values: LineSpec Default: - (solid line for) Values: number of points Default: 0.5 points Values: on, off Default: on Values: in, out
13

Matlab , Fall 2004

Lesson #7

Default: in (2-D), out (3-D) TickDirMode TickLength Use MATLAB or user-specified tick mark direction Length of tick marks normalized to axis line length, specified as two-element vector Make axes visible or invisible Toggle grid lines on and off in respective axis Handles of the images, lights, lines, patches, surfaces, and text objects displayed in the axes Values: auto, manual Default: auto Values: [2-D 3-D] Default: [0.01 0.025} Values: on, off Default: on Values: on, off Default: off Values: vector of handles

Visible XGrid, YGrid, ZGrid General Information About the Axes Children

CurrentPoint HitTest

Location of last mouse button Values: a 2-by-3 matrix click defined in the axes data units Specify whether axes can become Values: on, off the current object (see figure Default: on CurrentObject property) Handle of the figure window containing the axes Location and size of axes within the figure Indicate whether axes is in a "selected" state Values: scalar figure handle Values: [left bottom width height] Default: [0.1300 0.1100 0.7750 0.8150] in normalized Units Values: on, off Default: on
14

Parent Position

Selected

Matlab , Fall 2004

Lesson #7

Tag Type Units

User-specified label The type of graphics object (read only) Units used to interpret the Position property User-specified data

Values: any string Default: '' (empty string) Value: the string 'axes' Values: inches, centimeters, characters, normalized, points, pixels Default: normalized Values: any matrix Default: [] (empty matrix) Values: normal, italic, oblique Default: normal

UserData Selecting Fonts and Labels FontAngle FontName

Select italic or normal font

Font family name (e.g., Helvetica, Values: a font supported by your system or Courier) the string FixedWidth Default: Typically Helvetica Size of the font used for title and labels Units used to interpret the FontSize property Select bold or normal font Handle of the title text object Handles of the respective axis label text objects Specify tick mark labels for the Values: an integer in FontUnits Default: 10 Values: points, normalized, inches, centimeters, pixels Default: points Values: normal, bold, light, demi Default: normal Values: any valid text object handle Values: any valid text object handle Values: matrix of strings Defaults: numeric
15

FontSize FontUnits

FontWeight Title XLabel, YLabel, ZLabel XTickLabel, YTickLabel,

Matlab , Fall 2004

Lesson #7

ZTickLabel

respective axis

values selected automatically by MATLAB Values: auto, manual Default: auto Values: top, bottom Default: bottom Values: right left Default: left

XTickLabelMode, Use MATLAB or user-specified YTickLabelMode, ZTickLabelMode tick mark labels Controlling Axis Scaling XAxisLocation YAxisLocation XDir, YDir, ZDir XLim, YLim, ZLim Specify the location of the x-axis Specify the location of the y-axis

Specify the direction of increasing Values: normal, reverse Default: values for the respective axes normal Specify the limits to the respective Values: [min max] axes Default: min and max determined automatically by MATLAB Use MATLAB or user-specified values for the respective axis limits Values: auto, manual Default: auto

XLimMode, YLimMode, ZLimMode

XMinorGrid,YMinorGrid, ZMinorGrid

Determines whether MATLAB Values: on, off displays gridlines connecting Default: off minor tick marks in the respective axis. Determines whether MATLAB displays minor tick marks in the respective axis. Select linear or logarithmic scaling of the respective axis Specify the location of the axis Values: on, off Default: off Values: linear, log Default: linear (changed by plotting commands that create nonlinear plots) Values: a vector of data values locating tick
16

XMinorTick,YMinorTick,ZMinorTick

XScale, YScale, ZScale

XTick, YTick, ZTick

Matlab , Fall 2004

Lesson #7

ticks marks XTickMode, YTickMode, ZTickMode Controlling the View CameraPosition

marks Default: MATLAB automatically determines tick mark placement

Use MATLAB or user-specified Values: auto, manual values for the respective tick mark Default: auto locations Specify the position of point from Values: [x,y,z] axes coordinates which you view the scene Default: automatically determined by MATLAB Use MATLAB or user-specified camera position Center of view pointed to by camera Use MATLAB or user-specified camera target Direction that is oriented up Values: auto, manual Default: auto Values: [x,y,z] axes coordinates Default: automatically determined by MATLAB Values: auto, manual Default: auto Values: [x,y,z] axes coordinates Default: automatically determined by MATLAB Values: auto, manual Default: auto Values: angle in degrees between 0 and 180 Default: automatically determined by MATLAB Values: auto, manual Default: auto Values: orthographic, perspective
17

CameraPositionMode CameraTarget

CameraTargetMode CameraUpVector

CameraUpVectorMode CameraViewAngle

Use MATLAB or user-specified camera up vector Camera field of view

CameraViewAngleMode Projection

Use MATLAB or user-specified camera view angle Select type of projection

Matlab , Fall 2004

Lesson #7

Default: orthographic Controlling the Axes Aspect Ratio DataAspectRatio Relative scaling of data units Values: three relative values [dx dy dz] Default: automatically determined by MATLAB Values: auto, manual Default: auto Values: three relative values [dx dy dz] Default: automatically determined by MATLAB Values: auto, manual Default: auto

DataAspectRatioMode PlotBoxAspectRatio

Use MATLAB or user-specified data aspect ratio Relative scaling of axes plot box

PlotBoxAspectRatioMode Controlling Callback Routine Execution BusyAction

Use MATLAB or user-specified plot box aspect ratio

Specify how to handle events that Values: cancel, queue Default: queue interrupt execution callback routines Define a callback routine that Values: string or function handle executes when a button is pressed Default: an empty string over the axes Define a callback routine that executes when an axes is created Define a callback routine that executes when an axes is created Values: string or function handle Default: an empty string Values: string or function handle Default: an empty string

ButtonDownFcn

CreateFcn DeleteFcn Interruptible UIContextMenu

Control whether an executing Values: on, off Default: on callback routine can be interrupted Associate a context menu with the Values: handle of a Uicontextmenu axes
18

Matlab , Fall 2004

Lesson #7

Specifying the Rendering Mode DrawMode Targeting Axes for Graphics Display HandleVisibility NextPlot Control access to a specific axes' handle Determine the eligibility of the axes for displaying graphics Values: on, callback, off Default: on Values: add, replace, replacechildren Default: replace Values: [amin amax] Values: auto | manual Default: auto Specify the rendering method to use with the Painters renderer Values: normal, fast Default: normal

Properties that Specify Transparency ALim ALimMode Properties that Specify Color AmbientLightColor CLim

Alpha axis limits Alpha axis limits mode

Color of the background light in a Values: ColorSpec scene Default: [1 1 1] Control how data is mapped to colormap Use MATLAB or user-specified values for CLim Color of the axes background Line colors used for multiline plots Colors of the axis lines and tick marks Values: [cmin cmax] Default: automatically determined by MATLAB Values: auto, manual Default: auto Values: none, ColorSpec Default: none Values: m-by-3 matrix of RGB values Default: depends on color scheme used Values: ColorSpec Default: depends on current color scheme
19

CLimMode Color ColorOrder XColor, YColor, ZColor

Matlab , Fall 2004

Lesson #7

Create user interface control object. Usage: handle = uicontrol(...,'PropertyName',PropertyValue,...) uicontrol creates uicontrol graphics objects (user interface controls). You implement graphical user interfaces using uicontrols. When selected, most uicontrol objects perform a predefined action. styles of uicontrols: Check boxes Editable text fields Frames List boxes Pop-up menus Push buttons Radio buttons Sliders Static text labels Toggle buttons To create a specific type of uicontrol, set the Style property as one of the following strings: 'checkbox'- Check boxes generate an action when clicked on. These devices are useful when providing the user with a number of independent choices. To activate a check box, click the mouse button on the object. The state of the device is indicated on the display. 'edit' - Editable text fields enable users to enter or modify text values. Use editable text when you want text as input. On Microsoft Windows systems, if an editable text box has focus, clicking on the menu bar does not cause the editable text callback routine to execute. However, it does cause execution on UNIX systems. Therefore, after clicking on the menu bar, the statement o get(edit_handle,'String')
o

Uicontrolsuicontrol

does not return the current contents of the edit box on Microsoft Windows systems because MATLAB must execute the callback routine to update the String property (even though the text string has changed on the screen). This behavior is consistent with the respective platform conventions.
20

Matlab , Fall 2004

Lesson #7

'frame' - Frames are rectangles that provide a visual enclosure for regions of a figure window. Frames can make a user interface easier to understand by grouping related controls. Frames have no callback routines associated with them. Only other uicontrols can appear within frames. Frames are opaque, not transparent, so the order you define uicontrols is important in determining whether uicontrols within a frame are covered by the frame or are visible. Stacking order determines the order objects are drawn: objects defined first are drawn first; objects defined later are drawn over existing objects. If you use a frame to enclose objects, you must define the frame before you define the objects. 'listbox' - List boxes display a list of items (defined using the String property) and enable users to select one or more items. The Min and Max properties control the selection mode: If Max-Min>1, then multiple selection is allowed. If Max-Min<=1, then only single selection is allowed. The Value property indicates selected entries and contains the indices into the list of strings; a vector value indicates multiple selections. MATLAB evaluates the list box's callback routine after any mouse button up event that changes the Value property. Therefore, you may need to add a "Done" button to delay action caused by multiple clicks on list items. List boxes differentiate between single and double clicks and set the figure SelectionType property to normal or open accordingly before evaluating the list box's Callback property. 'popupmenu' - Popup menus open to display a list of choices (defined using the String property) when pressed. When not open, a pop-up menu indicates the current choice. Pop-up menus are useful when you want to provide users with a number of mutually exclusive choices, but do not want to take up the amount of space that a series of radio buttons requires. You must specify a value for the String property. 'pushbutton' - Push buttons generate an action when pressed. To activate a push button, click the mouse button on the push button. 'radiobutton' - Radio buttons are similar to check boxes, but are intended to be mutually exclusive within a group of related radio buttons (i.e., only one is in a pressed state at any given time). To activate a radio button, click the mouse button on the object. The state of the device is indicated on the display. Note that your code can implement the mutually exclusive behavior of radio buttons. 'slider' - Sliders accept numeric input within a specific range by enabling the user to move a sliding bar. Users move the bar by pressing the mouse button and dragging the pointer over the bar, or by clicking in the trough or on an arrow. The location of the bar indicates a numeric value, which is selected by releasing the mouse button. You can set the minimum, maximum, and current values of the slider.
21

Matlab , Fall 2004

Lesson #7

'text' - Static text boxes display lines of text. Static text is typically used to label other controls, provide directions to the user, or indicate values associated with a slider. Users cannot change static text interactively and there is no way to invoke the callback routine associated with it. 'toggle' - Toggle buttons are controls that execute callbacks when clicked on and indicate their state, either on or off. Toggle buttons are useful for building toolbars. Property Description Property Value

Property Name

Controlling Style and Appearance BackgroundColor CData ForegroundColor Object background color Truecolor image displayed on the control Color of text Object highlighted when selected Value: ColorSpec Default: system dependent Value: matrix Value: ColorSpec Default: [0 0 0] Value: on, off Default: on

SelectionHighlight

String Visible

Uicontrol label, also list box and Value: string pop-up menu items Uicontrol visibility Value: on, off Default: on

General Information About the Object Children Uicontrol objects have no children
22

Matlab , Fall 2004

Lesson #7

Enable

Enable or disable the uicontrol Uicontrol object's parent Whether object is selected Slider step size Type of uicontrol object

Value: on, inactive, off Default: on Value: scalar figure handle Value: on, off Default: off Value: two-element vector Default: [0.01 0.1] Value: pushbutton, togglebutton, radiobutton, checkbox, edit, text, slider, frame, listbox, popupmenu Default: pushbutton Value: string Value: string Value: string (read-only) Default: uicontrol Value: matrix

Parent Selected

SliderStep Style

Tag TooltipString Type UserData

User-specified object identifier Content of object's tooltip Class of graphics object User-specified data

Controlling the Object Position Position Units Size and location of uicontrol object Units to interpret position vector Value: position rectangle Default: [20 20 60 20] Value: pixels, normalized, inches, centimeters, points, characters. Default: pixels

Controlling Fonts and Labels


23

Matlab , Fall 2004

Lesson #7

FontAngle

Character slant Font family Font size Font size units

Value: normal, italic, oblique Default: normal Value: string Default: system dependent Value: size in FontUnits Default: system dependent Value: points, normalized, inches, centimeters, pixels Default: points Value: light, normal, demi, bold Default: normal Value: left, center, right Default: depends on uicontrol object Value: string

FontName FontSize FontUnits

FontWeight

Weight of text characters

HorizontalAlignment Alignment of label string String Uicontrol object label, also list box and pop-up menu items

Controlling Callback Routine Execution BusyAction Callback routine interruption Button press callback routine Control action Callback routine executed during object creation Value: cancel, queue Default: queue Value: string Value: string Value: string

ButtonDownFcn Callback CreateFcn

24

Matlab , Fall 2004

Lesson #7

DeleteFcn Interruptible

Callback routine executed during object deletion Callback routine interruption mode

Value: string Value: on, off Default: on

UIContextMenu

Uicontextmenu object associated Value: handle with the uicontrol

Information About the Current State ListboxTop Max Min Value Index of top-most string displayed in list box Maximum value (depends on uicontrol object) Minimum value (depends on uicontrol object) Value: scalar Default: [1] Value: scalar Default: object dependent Value: scalar Default: object dependent

Current value of uicontrol object Value: scalar or vector. Default: object dependent

Controlling Access to Objects HandleVisibility HitTest Whether handle is accessible from command line and GUIs Whether selectable by mouse click Value: on, callback, off Default: on Value: on, off Default: on

Also see help for : uimenu and uicontextmenu

25

Matlab , Fall 2004

Lesson #7

Figure
figure Create a figure graphics object. Usage: figure creates a new figure object using default property values. figure('PropertyName',PropertyValue,...) creates a new figure object using the values of the properties specified. MATLAB uses default values for any properties that you do not explicitly define as arguments. figure(h) does one of two things, depending on whether or not a figure with handle h exists. If h is the handle to an existing figure, figure(h) makes the figure identified by h the current figure, makes it visible, and raises it above all other figures on the screen. The current figure is the target for graphics output. If h is not the handle to an existing figure, but is an integer, figure(h) creates a figure, and assigns it the handle h. figure(h) where h is not the handle to a figure, and is not an integer, is an error. h = figure(...) returns the handle to the figure object. Property Name Positioning the Figure Position Units Location and size of figure Units used to interpret the Position property Value: a 4-element vector [left, bottom, width, height]. Default: depends on display Values: inches, centimeters, normalized, points, pixels, characters Default: pixels Property Description Property Value

Specifying Style and Appearance Color Color of the figure background Toggle the figure menu bar on and off Figure window title Values: ColorSpec Default: depends on color scheme (see colordef) Values: none, figure. Default: figure Values: string. Default: '' (empty string)
26

MenuBar Name

Matlab , Fall 2004

Lesson #7

NumberTitle

Display "Figure No. n", where n is the figure number Specify whether the figure window can be resized using the mouse Highlight figure when selected (Selected property set to on) Make the figure visible or invisible Select normal or modal window

Values: on, off Default: on Values: on, off Default: on Values: on, off Default: on Values: on, off. Default: on Values: normal, modal Default: normal

Resize

SelectionHighlight

Visible WindowStyle Controlling the Colormap Colormap Dithermap DithermapMode FixedColors MinColormap ShareColors Specifying Transparency Alphamap

The figure colormap Colormap used for truecolor data on pseudocolor displays Enable MATLAB-generated dithermap Colors not obtained from colormap Minimum number of system color table entries to use Allow MATLAB to share system color table slots

Values: m-by-3 matrix of RGB values Default: the jet colormap Values: m-by-3 matrix of RGB values Default: colormap with full range of colors Values: auto, manual. Default: manual Values: m-by-3 matrix of RGB values (read only) Values: scalar Default: 64 Values on, off. Default: on

The figure alphamap

m-by-1 matrix of alpha values


27

Matlab , Fall 2004

Lesson #7

Specifying the Renderer BackingStore DoubleBuffer Enable off screen pixel buffering Values: on, off. Default: on

Flash-free rendering for simple animations Values: on, off Default: off Rendering method used for screen and printing Values: painters, zbuffer, OpenGL Default: automatic selection by MATLAB

Renderer

General Information About the Figure Children Handle of any uicontrol, uimenu, and uicontextmenu objects displayed in the figure Values: vector of handles

Parent Selected

The root object is the parent of all figures Value: always 0 Indicate whether figure is in a "selected" state. User-specified label The type of graphics object (read only) User-specified data Automatic or user-selected renderer Values: on, off Default: on Value: any string Default: '' (empty string) Value: the string 'figure' Values: any matrix Default: [] (empty matrix) Values: auto, manual Default: auto

Tag Type UserData RendererMode

Information About Current State


28

Matlab , Fall 2004

Lesson #7

CurrentAxes CurrentCharacter CurrentObject CurrentPoint SelectionType Callback Routine Execution BusyAction ButtonDownFcn

Handle of the current axes in this figure The last key pressed in this figure

Values: axes handle Values: single character

Handle of the current object in this figure Values: graphics object handle Location of the last button click in this figure Mouse selection type Values: 2-element vector [x-coord, y-coord] Values: normal, extended, alt, open

Specify how to handle callback routine interruption Define a callback routine that executes when a mouse button is pressed on an unoccupied spot in the figure Define a callback routine that executes when you call the close command Define a callback routine that executes when a figure is created

Values: cancel, queue Default: queue Values: string or function handle Default: empty string Values: string or function handle Default: closereq Values: string or function handle Default: empty string

CloseRequestFcn CreateFcn DeleteFcn

Define a callback routine that executes Values: string or function handle when the figure is deleted (via close or Default: empty string delete) Determine if callback routine can be interrupted Define a callback routine that executes Values: on, off Default: on (can be interrupted) Values: string or function handle
29

Interruptible

KeyPressFcn

Matlab , Fall 2004

Lesson #7

when a key is pressed in the figure window ResizeFcn UIContextMenu WindowButtonDownFcn Define a callback routine that executes when the figure is resized Associate a context menu with the figure

Default: empty string Values: string or function handle Default: empty string Values: handle of a Uicontrextmenu

Define a callback routine that executes Values: string or function handle when you press the mouse button down in Default: empty string the figure Values: string or function handle Default: empty string Values: string or function handle Default: empty string

WindowButtonMotionFcn Define a callback routine that executes when you move the pointer in the figure WindowButtonUpFcn Controlling Access to Objects IntegerHandle Specify integer or noninteger figure handle Determine if figure handle is visible to users or not Determine if the figure can become the current object (see the figure CurrentObject property) Determine how to display additional graphics to this figure Define a callback routine that executes when you release the mouse button

Values: on, off Default: on (integer handle) Values: on, callback, off Default: on Values: on, off Default: on Values: add, replace, replacechildren Default: add

HandleVisibility HitTest

NextPlot Defining the Pointer

30

Matlab , Fall 2004

Lesson #7

Pointer

Select the pointer symbol

Values: crosshair, arrow, watch, topl, topr, botl, botr, circle, cross, fleur, left, right, top, bottom, fullcrosshair, ibeam, custom. Default: arrow Values: 16-by-16 matrix Default: set Pointer to custom and see Values: 2-element vector [row, column]. Default: [1,1]

PointerShapeCData

Data that defines the pointer Specify the pointer active spot

PointerShapeHotSpot

Properties That Affect Printing InvertHardcopy PaperOrientation Change figure colors for printing Horizontal or vertical paper orientation Control positioning figure on printed page Enable WYSIWYG printing of figure Size of the current PaperType specified in PaperUnits Select from standard paper sizes Units used to specify the PaperSize and PaperPosition Values: on, off. Default: on Values: portrait, landscape Default: portrait Values: 4-element vector [left, bottom, width, height] Values: auto, manual. Default: manual Values: [width, height] Values: see property description. Default: usletter Values: normalized, inches, centimeters, points Default: inches

PaperPosition PaperPositionMode PaperSize

PaperType PaperUnits

31

Anda mungkin juga menyukai