Professional Documents
Culture Documents
CENG 301.3 Graphics-042
CENG 301.3 Graphics-042
CENG 301.3 Graphics-042
Using MATLAB
2
Criteria for Good Graphics
• Purpose clear?
• Fonts legible?
3
Criteria for Good Graphics (contd.)
• Critical components defined?
4
The Type of Graphics in Matlab
• Line graph
2D
3D
• Bar graph
• Pie graph
• Ribbon graph
5
Select the Right Type of Graphic
• Purpose
Problem solving?
Persuasion and interpretation?
• Audience
What are their background?
What are they interested to know?
• Context
Presentation?
Report/Paper? 6
Context
• Presentation
Big titles, labels, etc.
Can use any color
Can use animation
• Report
Smaller titles, labels, etc.
Often just black and white
Animation impossible
7
2D Plot Tips
• Use the best line style/size for the situation.
8
An Example
• You have:
Vector 1: x(0:0.2:10);
Vector 2: sin(x);
Vector 3: cos(x);
9
A Simple Matlab Program
clear all;
X=[0:0.2:10];
sinx=sin(x);
cosx=cos(x);
plot(x,sinx,x,cosx);
xlabel('x');
ylabel('y');
title([‘sin and cos Functions']);
10
Default Plot Given by Matlab
sin and cos Functions
1
0.8
0.6
0.4
0.2
0
y
-0.2
-0.4
-0.6
-0.8
-1
0 1 2 3 4 5 6 7 8 9 10
x
11
We Want …
• Titles and labels bigger.
• Lines thicker.
• Data points.
• Legend.
12
Open the Property Editor
13
Edit Figure Properties
14
Edit Axes Properties
15
Edit Line Properties
16
A Better-Looking Figure
sin and cos Functions
1
0.5
0
y
-0.5
-1
0 2 4 6 8 10
x 17
Insert Legend
18
Edit Legend Properties
19
Insert Y Grid Line
20
Final
sin and cos Functions
1.5
sin(x)
cos(x)
1
0.5
0
y
-0.5
-1
-1.5
0 2 4 6 8 10
x 21
Frequently Used Functions
• “plot”
• “xlabel”, “ylabel”
• “title”
• “xlim”, “ylim”
• “axis”
• “legend”
• “errorbar”
• 3D plots
“plot3”
“mesh”
“surf”
• Movie
“getframe”
“movie”
24