Upload
omair-mir
View
230
Download
0
Embed Size (px)
Citation preview
8/2/2019 Frankkweb Word Format Matlab
1/15
How to Format a Matlab Graph 1
Jeffrey Donell
The Woodruff School of Mechanical Engineering
HOW FORMAT A MATLAB GRAPH
Jeffrey DonnellThe George W. Woodruff School of Mechanical Engineering
The Georgia Institute of TechnologyAtlanta, GA 30332
SummaryThis document reviews the steps that a beginner should take in order to adjust a Matlab plot for display in a printdocument. Specifically, this document explains:
1) How to scale the plot to frame the data.
2) How to display and adjust the legend.
3) How to adjust the display of data points and related model or uncertainty lines.
4) How to export a finished plot in various Windows-friendly formats.
8/2/2019 Frankkweb Word Format Matlab
2/15
How to Format a Matlab Graph 2
Jeffrey Donell
The Woodruff School of Mechanical Engineering
Experimental results are often represented graphically, and your graphs must package information clearly, sim-
ply and specifically. You achieve these goals byformatting your graphs or plots. Plotting tools, such as those in
Excel and in Matlab, can give you great control over your information display, but they do not do all the work for
you. After you generate a plot in Matlab, you must adjust that plots formatting in order to produce a good dis-
play. This document shows you the basic steps for adjusting a Matlab plots format, and it outlines the principles
you should follow in making your format adjustments.
We will show you how to adjust the graph shown below. Your experimental project results might be displayed in
a Matlab plot that looks like this:
This is a perfectly acceptable chart. It is rich with information, and it provides no distractions from that informa-
tion. Every line and axis has a specific label, with units easily visible. On the plot, paired/related data sets are
visually related by the coordinated weights and patterns of the lines. There is no distracting non-data information
on the plot.
8/2/2019 Frankkweb Word Format Matlab
3/15
How to Format a Matlab Graph 3
Jeffrey Donell
The Woodruff School of Mechanical Engineering
Your goal is to produce a clear and simple chart like that shown here. But when you prepare a plot using Mat-
labs defaults, your graph might look more like this:
In order to obtain the desired display, you need re-format this chart by hand. This document walks you through
the process of scaling the axes, adjusting the legends appearance and placement, and setting the appearance of
the data markers and model lines themselves.
General: Scale the Axes to Frame the Data
The first task in formatting a plot is to adjust the X- and Y-axes. As you do this, remember that your data should
dominate the plot. Consequently, you should adjust the axis scales to eliminate blank space on the sides, top and
bottom of the plot.
HOWEVER: When you adjust the axis scales, you will probably introduce distorting offsets from the origin
location on the chart; it is your job to determine whether these distortions are trivial or significant. You must
always be able to characterize and explain such distortions, and your specific decisions about axis scales should
take the problem of distortion into account. In this example, we assume that the problem of distortion is trivial,
and we will scale the axes to frame the data very tightly.
8/2/2019 Frankkweb Word Format Matlab
4/15
How to Format a Matlab Graph 4
Jeffrey Donell
The Woodruff School of Mechanical Engineering
1) Scale the Chart
In Matlab, Plot Editing must be enabled before you do anything. To do this, pull down the Tools menu and
select Enable Plot Editing:
Now Matlab will let you adjust the display.
8/2/2019 Frankkweb Word Format Matlab
5/15
How to Format a Matlab Graph 5
Jeffrey Donell
The Woodruff School of Mechanical Engineering
In order to scale the axes, you must preselect an axis by clicking on the plot. Then re-open the Tools pull-down
menu and select Axes Properties in order to begin editing:
With this selection made, the largeEdit Axes Properties dialog box opens, allowing you to adjust the maximum
and minimum values for each axis.
8/2/2019 Frankkweb Word Format Matlab
6/15
How to Format a Matlab Graph 6
Jeffrey Donell
The Woodruff School of Mechanical Engineering
Here, the Y-axis has been scaled to frame the data, y-grids have been removed and an axis label has been applied:
The changes have already been applied and are shown on the plot.
8/2/2019 Frankkweb Word Format Matlab
7/15
How to Format a Matlab Graph 7
Jeffrey Donell
The Woodruff School of Mechanical Engineering
Now the X-axis will be adjusted as well:
Unnecessary grids have been cleared, the axes are labeled and the data fills the whole of the chart.
8/2/2019 Frankkweb Word Format Matlab
8/15
How to Format a Matlab Graph 8
Jeffrey Donell
The Woodruff School of Mechanical Engineering
2) Adjust the Legend
The tools menu is pulled down and the Legend is selected for display:
In this image, the legend has already been selected, and it is shown in its default position at the top right corner of
the plot.
Matlab places the legend directly on the plot. In most cases, such placement saves space and allows for a larger
display; but this legend obscures some of the data. It must be moved to an empty region of the plot and it must be
edited to display the correct descriptions of the data series.
8/2/2019 Frankkweb Word Format Matlab
9/15
How to Format a Matlab Graph 9
Jeffrey Donell
The Woodruff School of Mechanical Engineering
To move the legend, simply select and drag it with the mouse. Then select and type over each entry to provide
specific descriptors for the different data series.
8/2/2019 Frankkweb Word Format Matlab
10/15
How to Format a Matlab Graph 10
Jeffrey Donell
The Woodruff School of Mechanical Engineering
The legend box resizes to accommodate long entries. The fully edited legend is shown below:
8/2/2019 Frankkweb Word Format Matlab
11/15
How to Format a Matlab Graph 11
Jeffrey Donell
The Woodruff School of Mechanical Engineering
3) Adjust the Display of Data Lines
To adjust the data display, each line must be selected and edited individually.
The principles for representing data sets are these:
--A single data set can be represented with markers only.
--When two or more data sets are presented, the markers are connected with straight (not smoothed) lines. Mark-
ers and lines must be visually distinct in order that the data sets can be distinguished.--When a model is graphed, it is represented as a smoothed line without markers.
--When several models are shown, they can be grouped or distinguished through use of similar (or distinct) line
patterns and weights.
The student must determine which sets of data or of models are to be grouped, and the student must be able to
explain any grouping decisions that s/he reaches.
Here, we seek to distinguish line types so that we can reproduce this graph in black and white. To do this, we
must adjust the line weights and line patterns--dots and dashes and the like. We must also be certain that our data
points are represented appropriately.
The Model - Umodel line--the bottom line of this chart--is adjusted first:
We select this line by double-clicking, and the Edit Line Properties dialog opens. This box offers a submenu
allowing you to specify the lines color, size and style. For this display, we will set line Color to black.
Matlabs default line width is too narrow for many printers to manage successfully; we will increase the 0.1
(point) line Size to 1.0. We select a line Style with wide dashes.
These selections, and the resulting graph, are shown in the following display:
8/2/2019 Frankkweb Word Format Matlab
12/15
How to Format a Matlab Graph 12
Jeffrey Donell
The Woodruff School of Mechanical Engineering
The other uncertainty bands are formatted in the same fashion. The -Umodel bands use the same dash pattern,
while the -Udata use a distinct, but coordinated dash pattern, as shown in the next illustration:
8/2/2019 Frankkweb Word Format Matlab
13/15
8/2/2019 Frankkweb Word Format Matlab
14/15
How to Format a Matlab Graph 14
Jeffrey Donell
The Woodruff School of Mechanical Engineering
Here, with the data series Lit formatted as a medium-width, solid line, the graph is fully formatted.
8/2/2019 Frankkweb Word Format Matlab
15/15
How to Format a Matlab Graph 15
Jeffrey Donell
The Woodruff School of Mechanical Engineering
4) Options for Exporting a Finished Plot
This finished graph can be copied directly for use in Word or PowerPoint, or from the File menu, it can be
exported in a variety of windows-friendly file formats.