02.03.2016 Views

MATLAB by rudra pratap

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.4 Handle Graphics<br />

211<br />

Understanding a vector of handles<br />

In the previous script file, you may perhaps be confused about the use of the handle<br />

hline. The command, hline=get (h, 'children'), gets the handles of all the children<br />

of the current axes (specified <strong>by</strong> handle h) in a column vector hline. The vector<br />

hline has seven elements-three handles for the three lines and four handles for the<br />

four text objects (created <strong>by</strong> text and gtext commands) . So, how do we know<br />

which handle is for which line or which text? The command get (hline ( i) , 'type ')<br />

lists the type of the object whose handle is hline(i). The confusion is not clear yet.<br />

What if hline(5), hline(6), and hline(7) are all lines? How do we know which<br />

handle corresponds to which line? Once we know the type of the object, we can<br />

identify its handle, among several similar object handles, <strong>by</strong> querying a more distinctive<br />

property of the object, such as linestyle for lines and string for text<br />

objects. For example, consider the handle vector hline given earlier. Then,<br />

get (hline (5) ,'marker')<br />

get (hline(6) ,'linestyle')<br />

get (hline (1) ,'string')<br />

get (hline(2) ,'string')<br />

returns o for the line style,<br />

returns -- for the line style,<br />

returns in Taylor series for the string, and<br />

returns First 3 terms for the string.<br />

From this example, it should be clear that the handles of children of the axes<br />

are listed in the stacking order of the objects, i.e., the last object added goes on the<br />

top of the stack. Thus, the elements of the handle vector correspond to the objects<br />

in the reverse order of their creation!<br />

Deleting graphics objects<br />

Any object in the graphics window can be deleted without disturbing the other<br />

objects with the command<br />

delete ( Ob jHand L e)<br />

where ObjHandle is the handle of the object. We have used this command in the<br />

script file that produced Fig. 6.13 to delete the text "linear approximation" from<br />

the figure. We could have used delete (hline (6)) to delete the corresponding line<br />

rather than making it invisible.<br />

Modifying plots with PropEdit<br />

Now that you have some understanding of Handle Graphics, object handles, and<br />

object properties, you may like to use the point-and-click graphics editor, PropEdit.<br />

Simply type propedi t to activate the editor. All graphics objects from the active<br />

figure window are shown, along with their properties, in the PropEdit window. Yo u<br />

can select a property from the list <strong>by</strong> clicking on it and then change it in the narrow<br />

rectangle in the middle. A graphics object with a plus ( +) on its left indicates that<br />

you can double-click on it to see its children.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!