CENG 301.3 Graphics-042

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 24

Designing Effective Graphics

Using MATLAB

The Cain Project in


Engineering and Professional Communication

Linda Driskill, driskila@ruf.rice.edu


Daniel Trahan, trahan@ruf.rice.edu
Gang Cheng, gang@rice.edu
The Purpose of Using Graphics
• In problem solving
 As part of design
 As analysis of operating data

• For persuasion and interpretation


 Dramatize relationships
 Promote identification
 Make complex information accessible

2
Criteria for Good Graphics
• Purpose clear?

• Pattern and arrangement lead eye without


distraction?

• Similar items grouped and indicated?

• Graphic hierarchy consistent?

• Fonts legible?
3
Criteria for Good Graphics (contd.)
• Critical components defined?

• Essential calculations behind claims shown?

• Any significant reference or standard


omitted?

• Presenters’ expertise demonstrated?

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.

• Think about the best placement of


legend/key.

• Incorporate error bars, if necessary.

• Use gridline sparingly.

8
An Example
• You have:
 Vector 1: x(0:0.2:10);
 Vector 2: sin(x);
 Vector 3: cos(x);

• You are asked to:


 Plot sin(x) vs. x and cos(x) vs. x in the same
figure;
 Customize the figure so that it is suitable for
presentation.

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.

• Colors more contrasting.

• 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”

• Type “help xxx” in Matlab command window


for detailed information on the usage of the
function xxx. 22
Other 2D Plotting Commands
• “loglog”: graph with logarithmic scales for
both axes.

• “semilogx”: graph with a logarithmic scale for


x-axis and a linear scale for y-axis.

• “semilogy”: graph with a logarithmic scale for


y-axis and a linear scale for x-axis.

• “plotyy”: graph with y-tick labels on the left


and right side.
23
A Whole Lot More …
• 2D contour
 “contour”
 “contourslice”

• 3D plots
 “plot3”
 “mesh”
 “surf”

• Movie
 “getframe”
 “movie”
24

You might also like