270 likes | 404 Views
Designing Effective Graphics Using MATLAB. The Cain Project in Engineering and Professional Communication Linda Driskill, driskila@ruf.rice.edu Gang Cheng, gang@rice.edu. The Purpose of Using Graphs. In problem solving As part of design As analysis of operating data
E N D
Designing Effective Graphics Using MATLAB The Cain Project in Engineering and Professional Communication Linda Driskill,driskila@ruf.rice.edu Gang Cheng,gang@rice.edu
The Purpose of Using Graphs • In problem solving • As part of design • As analysis of operating data • For persuasion and interpretation • Dramatize relationships • Promote identification • Make complex information accessible
Checklist for Good Graphics • Purpose clear? • Critical components defined? • Pattern and arrangement lead eye without distraction? • Graphic hierarchy consistent? • Fonts legible? • Presenter’s expertise shown?
Types of Graph in Matlab • Line graph • 2D • 3D • Bar graph • Pie graph • Ribbon graph
Considerations • Purpose • Problem solving? • Persuasion and interpretation? • Audience • What are their background? • What are they interested to know? • Context • Presentation? • Report/Paper?
Context • Presentation • Big fonts • Can use any color • Can use animation • Report • Smaller fonts • Often just black and white • Animation impossible
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 becomes suitable for being used in a presentation. • Customize the figure so that it becomes suitable for being used in a report/paper.
A Simple Matlab Program %start clear all; %clear the memory X=[0:0.2:10]; %define the x vector sinx=sin(x); %calculate sin(x) cosx=cos(x); %calculate sin(x) plot(x,sinx,x,cosx); %plot the lines xlabel('x'); %add x label ylabel('y'); %add y label title([‘sin and cos Functions']); %add title %end
We Want … • Titles and labels bigger. • Lines thicker. • Colors more contrasting. • Insert Legend. • Data points shown. • Try adding gridlines.
title Y label X label Tick and tick label Anatomy of a Matlab Figure Axes lines
Figure Properties Open the Property Editor
Figure Immediate apply Edit Figure Properties
axes Edit Axes Properties
line Edit Line Properties
legend Insert Legend
Legend Inserted Select object
legend Edit Legend Properties
axes Grid Show Insert Y Grid Line
Frequently Used Functions • “plot” • “xlabel”,“ylabel” • “title” • “xlim”, “ylim” • “axis” • “legend” • “errorbar” • Type “help function name” in Matlab command window for detailed information on the usage of the function.
Other 2D Plotting Functions • “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.
A Whole Lot More … • 2D contour • “contour” • “contourslice” • 3D plots • “plot3” • “mesh” • “surf” • Movie • “getframe” • “movie”
A Bioartificial Tissue Seeded with Cells Z = 40 Z = 1 Sample Movie A movie created with mesh, getframe and movie