Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 9 Plotting in 2-D Plotting in 2-D, Plotting Multiple Curves, Plotting with Figures, Plot Settings, Scaling, Legends © 2007 Daniel Valentine. All.

Similar presentations


Presentation on theme: "Lecture 9 Plotting in 2-D Plotting in 2-D, Plotting Multiple Curves, Plotting with Figures, Plot Settings, Scaling, Legends © 2007 Daniel Valentine. All."— Presentation transcript:

1 Lecture 9 Plotting in 2-D Plotting in 2-D, Plotting Multiple Curves, Plotting with Figures, Plot Settings, Scaling, Legends © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.

2 Usefulness of plotting data Large sets of data are usually difficult to interpret as tables of numbers. Large sets of data are usually difficult to interpret as tables of numbers. Engineers and scientists use graphical techniques to reduce large sets of data to help gain insight. Engineers and scientists use graphical techniques to reduce large sets of data to help gain insight. With graphical presentations, insightful trends and possible errors are more easily identified. With graphical presentations, insightful trends and possible errors are more easily identified.

3 2-D, (x, y) plots Creating (x, y) plots is easy with plot, e.g.: Creating (x, y) plots is easy with plot, e.g.: Type two vectors: Type two vectors: Use the plot() Use the plot() command: command:

4 Add a grid Use the grid command to add a grid to the figure. Use the grid command to add a grid to the figure.

5 Add a title and labels Add a title and labels to a plot as illustrated in the example: Add a title and labels to a plot as illustrated in the example:

6 Plot multiple curves on a figure

7 The hold command Multiple plots can be added to a figure using the hold command. Multiple plots can be added to a figure using the hold command. …

8 Multiple figures Single (or multiple) plots can be created in multiple figures. A two-figures example: Single (or multiple) plots can be created in multiple figures. A two-figures example:

9 Note: MATLAB gives a warning that imaginary parts are ignored. Note: MATLAB gives a warning that imaginary parts are ignored. Plots of complex numbers If input to the plot function is complex, MATLAB plots the real component on the x-axis and the imaginary on the y-axis. Alternatively, if If input to the plot function is complex, MATLAB plots the real component on the x-axis and the imaginary on the y-axis. Alternatively, if

10 Changing line style, point style, and color To plot the data with To plot the data with a red, dash-dot line a red, dash-dot line with red stars for with red stars for points: points:

11 Table of options Line type Indicator Point type IndicatorColorIndicator solid-point.blueb dotted:circleogreeng dash-dot-.x-markxredr dashed--plus+cyanc star*magentam squaresyellowy diamonddblackk triangle down v triangle up ^ triangle left < triangle right > pentagramp hexagramh

12 Plotting individual data points Setting a marker type without specifying a line type will suppress the straight line drawn by default between the points that define the lines. Setting a marker type without specifying a line type will suppress the straight line drawn by default between the points that define the lines.

13 Re-scaling the axis If you do not like the fact that the curve touches the axis, you can change the scale as follows: If you do not like the fact that the curve touches the axis, you can change the scale as follows:

14 Annotations with figures

15 Addition of legends

16 Special characters in legends Use the help feature to search for how to input other special characters. Use the help feature to search for how to input other special characters. Search for 'text properties. ' Search for 'text properties. '

17 Exercises In one figure, plot y1 = x 2 - 2x + 3 and In one figure, plot y1 = x 2 - 2x + 3 and y2 = -x 3 + 3x + 1/x for x = -10 to x = 10. Make y1 a solid line with green diamond points and y2 a dashed line with cyan x-mark points. Add a legend with both curves listed in it. In a second figure, plot y1 = tan(x) and y2 = sin(x)^2 from x = -π to x = π. Scale the axes appropriately and add a grid. In a second figure, plot y1 = tan(x) and y2 = sin(x)^2 from x = -π to x = π. Scale the axes appropriately and add a grid.

18 Summary Plotting in 2-D Plotting in 2-D Adding a grid, title, labels, text, and a legend to a plot Adding a grid, title, labels, text, and a legend to a plot Scaling the axis on a plot Scaling the axis on a plot Plotting multiple curves on a figure Plotting multiple curves on a figure Plotting using multiple figures Plotting using multiple figures Plotting complex arrays Plotting complex arrays Changing line style, color, and point style Changing line style, color, and point style


Download ppt "Lecture 9 Plotting in 2-D Plotting in 2-D, Plotting Multiple Curves, Plotting with Figures, Plot Settings, Scaling, Legends © 2007 Daniel Valentine. All."

Similar presentations


Ads by Google