Graphics Programs Reference
In-Depth Information
Customizing and Manipulating
Graphics
This is a more advanced topic; if you wish you can skip it on a first reading.
So far in this chapter, we have discussed the most commonly used MATLAB
routinesforgeneratingplots.Butoften,togettheresultsonewants,oneneeds
to customize or manipulate the graphics these commands produce. Knowing
how to do this requires understanding a few basic principles concerning the
way MATLAB stores and displays graphics. For most purposes, the discussion
here will be sufficient. But if you need more information, you might eventually
want to consult one of the topics devoted exclusively to MATLAB graphics,
suchas Using MATLABGraphics , which comes free (in PDF format) with
the software and can be accessed in the “MATLAB Manuals” subsection of
the “Printable Documentation” section in the Help Browser (or under “Full
DocumentationSet”fromthe helpdesk inMATLAB5.3andearlierversions),
or Graphics and GUIs with MATLAB , 2nd ed., by P. Marchand, CRC Press,
Boca Raton, FL, 1999.
In a typical MATLAB session, one may have many figure windows open
at once. However, only one of these can be “active” at any one time. One can
find out whichfigure is active withthe command gcf , short for “get current
figure,” and one can change the active figure to, say, figure number 5 with the
command figure(5) , or else by clicking on figure window 5 withthe mouse.
The command figure (withno arguments) creates a blank figure window.
(This is sometimes useful if you want to avoid overwriting an existing plot.)
Once a figure has been created and made active, there are two basic ways to
manipulateit.TheactivefigurecanbemodifiedbyMATLABcommandsinthe
command window, suchas the commands title and axis square that we
have already encountered. Or one can modify the figure by using the menus
and/ortoolsinthefigurewindowitself.Let'sconsiderafewexamples.Toinsert
labels or text into a plot, one may use the commands text , xlabel , ylabel ,
zlabel , and legend , in addition to title . As the names suggest, xlabel ,
ylabel , and zlabel add text next to the coordinate axes, legend puts a
“legend” on the plot, and text adds text at a specific point. These commands
take various optional arguments that can be used to change the font family
and font size of the text. As an example, let's illustrate how to modify our plot
of the lemniscate (Figure 5-3) by adding and modifying text:
>> figure(3)
>> title('The lemniscate xˆ2-yˆ2=(xˆ2+yˆ2)ˆ2',...
Search WWH ::




Custom Search