MATLAB The Language of Technical Computing Computation Visualization Programming Using MATLAB Graphics The MathWorks Version 6
Computation Visualization Programming Using MATLAB Graphics Version 6 MATLABÆ The Language of Technical Computing
Contents ap h cs Overview of MATLAB Graphics Plotting Your Data ofa plot Editing Plots Interactive Plot editing Using Functions to Edit graphs 14 Using Plot Edit Mode Starting Plot Edit Mode 1-6 Exiting Plot Edit Mode l-6 cting Objects in a graph 1-6 Cutting, Copying, and Pasting Objects Moving and Resizing Objects diting objects in a graph Saving Your Work 1-9 Saving a graph in Mat-File Format Printing figures 1-10 Getting Help 1-12 Changing Your View 1-13 ooming In and Out Rotating 3-D Axes 1-14 Using the Property Editor Starting the Property Editor
i Contents Graphics 1 Overview of MATLAB Graphics Plotting Your Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 Anatomy of a Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 Editing Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Interactive Plot Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Using Functions to Edit Graphs . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Using Plot Edit Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5 Starting Plot Edit Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6 Exiting Plot Edit Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6 Selecting Objects in a Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6 Cutting, Copying, and Pasting Objects . . . . . . . . . . . . . . . . . . . 1-7 Moving and Resizing Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 Editing Objects in a Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8 Saving Your Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9 Saving a Graph in MAT-File Format . . . . . . . . . . . . . . . . . . . . . 1-9 Saving to a Different Format (Exporting Figures) . . . . . . . . . 1-10 Printing Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10 Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12 Changing Your View of an Axes . . . . . . . . . . . . . . . . . . . . . . . 1-13 Zooming In and Out on an Axes . . . . . . . . . . . . . . . . . . . . . . . . 1-13 Rotating 3-D Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14 Using the Property Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15 Starting the Property Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
Closing the Property Editor Editing Object Properties 1-17 Navigating Among Objects in a graph l-18 Identifying Objects in a graph Applying Your Changes 1-21 Using the Data Statistics Tool 1-22 Adding Plots of Statistics to a graph 1-22 Saving Statistics to the Workspace 1-23 Basic Plotting 2 Basic Plotting Commands 2-2 Creating Line Plots 2-2 Specifying Line Style Specifying the Color and Size of Lines 2-6 Adding Plots to an Existing graph 27 Plotting Only the Data Points 2-8 Plotting Markers and Lines 2-9 Line Styles for Black and white Output 2-10 Setting Default Line Styles Line plots of matrix Data 2-13 Plotting Imaginary and Complex Data Plotting with Two Y-Axes 2-16 Combining Linear and Logarithmic Axes 2-16 Setting Axis Parameters Axis Limits and Ticks Example- Specifying Ticks and Tick Labels 2-22 Setting Aspect Ratio Figure Windows Displaying Multiple Plots per Figure
ii Contents Closing the Property Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17 Editing Object Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17 Navigating Among Objects in a Graph . . . . . . . . . . . . . . . . . . . 1-18 Identifying Objects in a Graph . . . . . . . . . . . . . . . . . . . . . . . . . 1-20 Applying Your Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-21 Using the Data Statistics Tool . . . . . . . . . . . . . . . . . . . . . . . . 1-22 Adding Plots of Statistics to a Graph . . . . . . . . . . . . . . . . . . . . 1-22 Saving Statistics to the Workspace . . . . . . . . . . . . . . . . . . . . . . 1-23 2 Basic Plotting Basic Plotting Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Creating Line Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Specifying Line Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 Specifying the Color and Size of Lines . . . . . . . . . . . . . . . . . . . . 2-6 Adding Plots to an Existing Graph . . . . . . . . . . . . . . . . . . . . . . . 2-7 Plotting Only the Data Points . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 Plotting Markers and Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 Line Styles for Black and White Output . . . . . . . . . . . . . . . . . 2-10 Setting Default Line Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11 Line Plots of Matrix Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13 Plotting Imaginary and Complex Data . . . . . . . . . . . . . . . . . 2-15 Plotting with Two Y-Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16 Combining Linear and Logarithmic Axes . . . . . . . . . . . . . . . . . 2-16 Setting Axis Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19 Axis Limits and Ticks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19 Example – Specifying Ticks and Tick Labels . . . . . . . . . . . . . . 2-22 Setting Aspect Ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23 Figure Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26 Displaying Multiple Plots per Figure . . . . . . . . . . . . . . . . . . . . 2-26
Specifying the Target Axes Default color Scheme 2-28 Formatting Graphs Overview 3-2 Adding Titles to Graphs Using the Title Option on the Insert Menu 33 Using the property Editor to Add a Title Using the title Function Adding Legends to Graphs 36 Using the Legend Option on the Insert Menu 7 Using the Legend Function Positioning the legend Editing the legend 39 Removing the legend 3-10 Adding Axis Labels to Graphs 3-11 Using the Label Options on the Insert Menu Using the Property Editor to Add Axis labels Using Axis-Label Commands 3-15 Adding Text Annotations to Grap 3-17 Creating Text Annotations in Plot Editing Mode 3-18 Creating Text Annotations with the text or gtext Command.3-18 Text Alignment Example- Aligning Text 3-23 Editing Text Annotations Mathematical Symbols, Greek Letters, and TeX Characters. 3-25 Using Character and Numeric Variables in Text Example- Multiline Text Adding Arrows and Lines to Graphs ..3-31
iii Specifying the Target Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28 Default Color Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-28 3 Formatting Graphs Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 Adding Titles to Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Using the Title Option on the Insert Menu . . . . . . . . . . . . . . . . 3-3 Using the Property Editor to Add a Title . . . . . . . . . . . . . . . . . . 3-4 Using the title Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5 Adding Legends to Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6 Using the Legend Option on the Insert Menu . . . . . . . . . . . . . . 3-7 Using the Legend Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7 Positioning the Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8 Editing the Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 Removing the Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10 Adding Axis Labels to Graphs . . . . . . . . . . . . . . . . . . . . . . . . . 3-11 Using the Label Options on the Insert Menu . . . . . . . . . . . . . . 3-12 Using the Property Editor to Add Axis labels . . . . . . . . . . . . . 3-12 Using Axis-Label Commands . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15 Adding Text Annotations to Graphs . . . . . . . . . . . . . . . . . . . . 3-17 Creating Text Annotations in Plot Editing Mode . . . . . . . . . . 3-18 Creating Text Annotations with the text or gtext Command . 3-18 Text Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22 Example – Aligning Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23 Editing Text Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24 Mathematical Symbols, Greek Letters, and TeX Characters . 3-25 Using Character and Numeric Variables in Text . . . . . . . . . . 3-27 Example - Multiline Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-28 Drawing Text in a Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29 Adding Arrows and Lines to Graphs . . . . . . . . . . . . . . . . . . . 3-31
Creating Arrows and Lines in Plot Editing Mode Editing Arrows and Line Annotations Adding Plots of Basic Statistics to Graphs 3-33 Example- Plotting the Mean of a Data Set 3-34 Formatting Plots of Data Statistics 3-36 Statistics Plotted by the Data Statistics Tool 3-36 Viewing Statistics for Multiple Plots 3-37 Saving Statistics to the mATLAB Workspace Creating Specialized Plots Bar and Area graphs Types of Bar graphs 42 Stacked Bar graphs to Show Contributing Amount 45 Specifying X-Axis Data 4-7 Overlaying Plots on Bar graphs 4-9 Area graphs 4-11 Comparing Datasets with Area graphs 4-12 Pie Charts 4-14 Removing a Piece from a Pie Charts 416 Histograms 4-17 Histograms in Cartesian Coordinate Systems 4-17 Histograms in Polar Coordinates 419 Specifying Number 4-20 Discrete Data Graphs 4-22 4-22 Combining Stem Plots with Line Plots 4-25 Three-Dimensional stem plots 4-26 Stairstep Plots Direction and Velocity Vector Graphs ompass Plot ..4-3
iv Contents Creating Arrows and Lines in Plot Editing Mode . . . . . . . . . . 3-31 Editing Arrows and Line Annotations . . . . . . . . . . . . . . . . . . . 3-32 Adding Plots of Basic Statistics to Graphs . . . . . . . . . . . . . . 3-33 Example - Plotting the Mean of a Data Set . . . . . . . . . . . . . . . 3-34 Formatting Plots of Data Statistics . . . . . . . . . . . . . . . . . . . . . 3-36 Statistics Plotted by the Data Statistics Tool . . . . . . . . . . . . . . 3-36 Viewing Statistics for Multiple Plots . . . . . . . . . . . . . . . . . . . . 3-37 Saving Statistics to the MATLAB Workspace . . . . . . . . . . . . . 3-38 4 Creating Specialized Plots Bar and Area Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 Types of Bar Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 Stacked Bar Graphs to Show Contributing Amounts . . . . . . . . 4-5 Specifying X-Axis Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7 Overlaying Plots on Bar Graphs . . . . . . . . . . . . . . . . . . . . . . . . . 4-9 Area Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11 Comparing Datasets with Area Graphs . . . . . . . . . . . . . . . . . . 4-12 Pie Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14 Removing a Piece from a Pie Charts . . . . . . . . . . . . . . . . . . . . . 4-16 Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17 Histograms in Cartesian Coordinate Systems . . . . . . . . . . . . . 4-17 Histograms in Polar Coordinates . . . . . . . . . . . . . . . . . . . . . . . 4-19 Specifying Number of Bins . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20 Discrete Data Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22 Two–Dimensional Stem Plots . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22 Combining Stem Plots with Line Plots . . . . . . . . . . . . . . . . . . . 4-25 Three-Dimensional Stem Plots . . . . . . . . . . . . . . . . . . . . . . . . . 4-26 Stairstep Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-29 Direction and Velocity Vector Graphs . . . . . . . . . . . . . . . . . . 4-31 Compass Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-31
Feather plot Two-Dimensional Quiver Plots 4-34 Three-Dimensional Quiver Plots ..4-35 Contour plots Creating Simple Contour Plots 437 Labeling Contours 4-39 Filled Contours 4-40 Drawing a single Contour Line at a desired level The Contouring algorithm 4-42 Changing the offset of a Contour Displaying Contours in Polar Coordinates Interactive Plotting 4-48 Animation 4-50 4-50 Example- Visualizing an fft as a movie Erase modes 4-52 Displaying Bit-Mapped Images 5 Overview... 52 Images in MATLAB Bit Depth Support Data Types 5-6 Indexed Images .5-6 Intensity Images 57 RGB(Truecolor) Images 59 Working with 8-Bit and 16-Bit Images 8-Bit and 16-Bit Indexed Images 8-Bit and 16-Bit Intensity Images
v Feather Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-32 Two-Dimensional Quiver Plots . . . . . . . . . . . . . . . . . . . . . . . . . 4-34 Three-Dimensional Quiver Plots . . . . . . . . . . . . . . . . . . . . . . . . 4-35 Contour Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-37 Creating Simple Contour Plots . . . . . . . . . . . . . . . . . . . . . . . . . 4-37 Labeling Contours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-39 Filled Contours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40 Drawing a Single Contour Line at a Desired Level . . . . . . . . . 4-41 The Contouring Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-42 Changing the Offset of a Contour . . . . . . . . . . . . . . . . . . . . . . . 4-43 Displaying Contours in Polar Coordinates . . . . . . . . . . . . . . . . 4-44 Interactive Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-48 Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-50 Movies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-50 Example – Visualizing an FFT as a Movie . . . . . . . . . . . . . . . . 4-51 Erase Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-52 5 Displaying Bit-Mapped Images Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 Images in MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 Bit Depth Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 Image Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6 Indexed Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6 Intensity Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7 RGB (Truecolor) Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9 Working with 8-Bit and 16-Bit Images . . . . . . . . . . . . . . . . . . 5-11 8-Bit and 16-Bit Indexed Images . . . . . . . . . . . . . . . . . . . . . . . 5-11 8-Bit and 16-Bit Intensity Images . . . . . . . . . . . . . . . . . . . . . . 5-12
8-Bit and 16-Bit RGB Images Mathematical Operations Support for uint8 and uint16 5-13 Other 8-Bit and 16-Bit Array Support Summary of Image Types and Numeric Classes 14 Reading, Writing, and Querying Graphics Image Files.. 5-15 Reading a graphics Image Writing a graphics Image 5-16 Obtaining Information About Graphics Files 516 Displaying Graphics Images Summary of Image Types and Display Methods Controlling Aspect Ratio and Display Size 5-19 The Image object and Its Properties 523 CData 523 CDataMapping XData and ydata 524 EraseMode 5-26 Printing Images Converting the Data or graphic Type of Imag Printing and Exporting 6 Overview of Printing and Exporting 2 Print and Export Operations Graphical User Interfaces 62 Command line interface .6-3 Specifying Parameters and Options ...6-5 Default Settings and How to Change Them 6-6 How to Print or Export 6-9 Printing a Figure 6-9 Printing to a File
vi Contents 8-Bit and 16-Bit RGB Images . . . . . . . . . . . . . . . . . . . . . . . . . . 5-12 Mathematical Operations Support for uint8 and uint16 . . . . . 5-13 Other 8-Bit and 16-Bit Array Support . . . . . . . . . . . . . . . . . . . 5-13 Summary of Image Types and Numeric Classes . . . . . . . . . . . 5-14 Reading, Writing, and Querying Graphics Image Files . . . 5-15 Reading a Graphics Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15 Writing a Graphics Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-16 Obtaining Information About Graphics Files . . . . . . . . . . . . . 5-16 Displaying Graphics Images . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18 Summary of Image Types and Display Methods . . . . . . . . . . . 5-19 Controlling Aspect Ratio and Display Size . . . . . . . . . . . . . . . . 5-19 The Image Object and Its Properties . . . . . . . . . . . . . . . . . . . 5-23 CData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23 CDataMapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-23 XData and YData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24 EraseMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26 Printing Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28 Converting the Data or Graphic Type of Images . . . . . . . . 5-29 6 Printing and Exporting Overview of Printing and Exporting . . . . . . . . . . . . . . . . . . . . 6-2 Print and Export Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 Graphical User Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 Command Line Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3 Specifying Parameters and Options . . . . . . . . . . . . . . . . . . . . . . 6-5 Default Settings and How to Change Them . . . . . . . . . . . . . . . . 6-6 How to Print or Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9 Printing a Figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9 Printing to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13
Exporting to a File Exporting to the windows Clipboard Examples of Basic Operations Printing a Figure at screen Size 6-23 Printing with a Specific Paper Size 6-24 Printing a Centered Figure Exporting in a Specific graphics Format 6-26 Exporting in EPS Format with a TIFF Preview Exporting a figure to the clipboard Changing a Figure' s Settings electing the Figure 6-33 Selecting the Printer Setting the figure Size and Position 6-34 Setting the Paper Size or Type 6-38 Setting the Paper Orientation electing a renderer tting the resolut Setting the Axes Ticks and Limits 6-47 Setting the background Color 6-49 Setting Line and Text Characteristics 6-50 Setting the line and Text Color Setting CMyK Color 6-54 Excluding User Interface Controls Producing Uncropped Figures 6-55 Choosing a graphics Format Frequently Used Graphics Formats Factors to Consider in Choosing a Format Properties Affected by Choice of Format 661 Impact of Rendering Method on the Output 6-63 Description of Selected Graphics Formats 6-63 How to Specify a Format for Exporting 6-66 Choosing a Printer Driver Types of Printer Drivers 668 Factors to Consider in Choosing a driver Driver-Specific Information .......6-72 How to Specify the Printer Driver to Use 6-76
vii Exporting to a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15 Exporting to the Windows Clipboard . . . . . . . . . . . . . . . . . . . . 6-20 Examples of Basic Operations . . . . . . . . . . . . . . . . . . . . . . . . . 6-23 Printing a Figure at Screen Size . . . . . . . . . . . . . . . . . . . . . . . . 6-23 Printing with a Specific Paper Size . . . . . . . . . . . . . . . . . . . . . . 6-24 Printing a Centered Figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-25 Exporting in a Specific Graphics Format . . . . . . . . . . . . . . . . . 6-26 Exporting in EPS Format with a TIFF Preview . . . . . . . . . . . 6-27 Exporting a Figure to the Clipboard . . . . . . . . . . . . . . . . . . . . . 6-28 Changing a Figure’s Settings . . . . . . . . . . . . . . . . . . . . . . . . . . 6-31 Selecting the Figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-33 Selecting the Printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-33 Setting the Figure Size and Position . . . . . . . . . . . . . . . . . . . . 6-34 Setting the Paper Size or Type . . . . . . . . . . . . . . . . . . . . . . . . . 6-38 Setting the Paper Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . 6-39 Selecting a Renderer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-41 Setting the Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-44 Setting the Axes Ticks and Limits . . . . . . . . . . . . . . . . . . . . . . 6-47 Setting the Background Color . . . . . . . . . . . . . . . . . . . . . . . . . . 6-49 Setting Line and Text Characteristics . . . . . . . . . . . . . . . . . . . 6-50 Setting the Line and Text Color . . . . . . . . . . . . . . . . . . . . . . . . 6-52 Setting CMYK Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-54 Excluding User Interface Controls . . . . . . . . . . . . . . . . . . . . . . 6-55 Producing Uncropped Figures . . . . . . . . . . . . . . . . . . . . . . . . . . 6-55 Choosing a Graphics Format . . . . . . . . . . . . . . . . . . . . . . . . . . 6-57 Frequently Used Graphics Formats . . . . . . . . . . . . . . . . . . . . . 6-58 Factors to Consider in Choosing a Format . . . . . . . . . . . . . . . . 6-59 Properties Affected by Choice of Format . . . . . . . . . . . . . . . . . 6-61 Impact of Rendering Method on the Output . . . . . . . . . . . . . . 6-63 Description of Selected Graphics Formats . . . . . . . . . . . . . . . . 6-63 How to Specify a Format for Exporting . . . . . . . . . . . . . . . . . . 6-66 Choosing a Printer Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-68 Types of Printer Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-68 Factors to Consider in Choosing a Driver . . . . . . . . . . . . . . . . . 6-69 Driver-Specific Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-72 How to Specify the Printer Driver to Use . . . . . . . . . . . . . . . . . 6-76
Printing Problems 6-79 Exporting Problems 6-82 General Problems Handle graphics Objects 7 Graphics Object Hierarchy 7-2 Types of Graphics Objects 7-3 Handle graphics Objects 78 Changing Values 78 Default values 7-8 Properties Common to All Objects 7-9 Graphics Object Creation Functions Example- Creating Graphics Objects∴… 7-11 Parenting High-Level Versus Low-Level 7-14 Simplified Calling Syntax Setting and querying Property valu 7-17 Setting Property values querying Property Values 7-19 Factory-Defined Property Values Setting Default Property values 7-22 How matlAB Searches for Default values Defining Default Values Examples- Setting Default Line Styles 7-25 Accessing Object Handles 729 The Current Figure, Axes, and Object 7-29 Searching for Objects by Property Values-findobj
viii Contents Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-78 Printing Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-79 Exporting Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-82 General Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-86 7 Handle Graphics Objects Graphics Object Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2 Types of Graphics Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3 Handle Graphics Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4 Object Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8 Changing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8 Default Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8 Properties Common to All Objects . . . . . . . . . . . . . . . . . . . . . . . 7-9 Graphics Object Creation Functions . . . . . . . . . . . . . . . . . . . 7-11 Example — Creating Graphics Objects . . . . . . . . . . . . . . . . . . 7-12 Parenting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14 High-Level Versus Low-Level . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14 Simplified Calling Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-15 Setting and Querying Property Values . . . . . . . . . . . . . . . . . 7-17 Setting Property Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-17 Querying Property Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19 Factory-Defined Property Values . . . . . . . . . . . . . . . . . . . . . . . 7-21 Setting Default Property Values . . . . . . . . . . . . . . . . . . . . . . . 7-22 How MATLAB Searches for Default Values . . . . . . . . . . . . . . . 7-22 Defining Default Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-24 Examples — Setting Default LineStyles . . . . . . . . . . . . . . . . . 7-25 Accessing Object Handles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-29 The Current Figure, Axes, and Object . . . . . . . . . . . . . . . . . . . 7-29 Searching for Objects by Property Values — findobj . . . . . . . . 7-31
Deleting obj 7-34 Controlling Graphics Output Specifying the Target for Graphics Output 7-36 Preparing Figures and Axes for graphics Targeting Graphics Output with newplot 7-38 Example-Using newplot 7-39 Testing for Hold State Protecting Figures and Axes 7-42 The Close Request Function Handle validity Versus Handle visibility Saving Handles in M-Files 7-47 Properties Changed by Built-In Functions 7-48 Callback Properties for Graphics Objects Graphics Object Callbacks 7-51 Uicontrol. Uimenu. and Uicontextmenu callbacks 7-51 Figures Callbacks Function handle callbacks 7-53 Function Handle Syntax Why Use Function Handle Callbacks 7-54 Example- Using Function Handles in a gUi igure Properties 8 Figure Objects 9=2 Positioning Figures 9-3 The position vector Example- Specifying Figure Position Controlling How MATLAB Uses Cole 97
ix Copying Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-32 Deleting Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-34 Controlling Graphics Output . . . . . . . . . . . . . . . . . . . . . . . . . . 7-36 Specifying the Target for Graphics Output . . . . . . . . . . . . . . . 7-36 Preparing Figures and Axes for Graphics . . . . . . . . . . . . . . . . 7-36 Targeting Graphics Output with newplot . . . . . . . . . . . . . . . . 7-38 Example — Using newplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-39 Testing for Hold State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-41 Protecting Figures and Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-42 The Close Request Function . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-44 Handle Validity Versus Handle Visibility . . . . . . . . . . . . . . . . 7-45 Saving Handles in M-Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47 Properties Changed by Built-In Functions . . . . . . . . . . . . . 7-48 Callback Properties for Graphics Objects . . . . . . . . . . . . . . 7-51 Graphics Object Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-51 Uicontrol, Uimenu, and Uicontextmenu Callbacks . . . . . . . . . 7-51 Figures Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-51 Function Handle Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-53 Function Handle Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-53 Why Use Function Handle Callbacks . . . . . . . . . . . . . . . . . . . . 7-54 Example — Using Function Handles in a GUI . . . . . . . . . . . . 7-56 8 Figure Properties Figure Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2 Positioning Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 The Position Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 Example – Specifying Figure Position . . . . . . . . . . . . . . . . . . . . 9-5 Controlling How MATLAB Uses Color . . . . . . . . . . . . . . . . . . 9-7