PLOTS AND FIGURES DAVID COOPER SUMMER 2014. Plots One of the primary uses for MATLAB is to be able to create publication quality figures from you data.

Slides:



Advertisements
Similar presentations
Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
Advertisements

CSE 123 Plots in MATLAB. Easiest way to plot Syntax: ezplot(fun) ezplot(fun,[min,max]) ezplot(fun2) ezplot(fun2,[xmin,xmax,ymin,ymax]) ezplot(fun) plots.
Introduction to Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Plotting Selim Aksoy Bilkent University Department of Computer Engineering
2D Plots 1 ENGR 1181 MATLAB 12.
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 4.
FIRST COURSE Excel Tutorial 4 Working with Charts and Graphics.
Microsoft Excel 2010 Chapter 7
MATLAB GRAPHICS 2-D.
McGraw-Hill Technology Education © 2004 by the McGraw-Hill Companies, Inc. All rights reserved. Office Excel 2003 Lab 2 Charting Worksheet Data.
MATLAB - Lecture 22A Two Dimensional Plots / Chapter 5 Topics Covered:
EGR106 Week 6 MATLAB FILES Two Dimensional Plots Multiple Plots
Vectors and Plotting Selim Aksoy Bilkent University Department of Computer Engineering
MATLAB Week 3 17 November Outline Graphics – Basic plotting – Editing plots from GUI – Editing plots from m-file – Advanced plotting commands.
EGR106 Week 4 Two Dimensional Plots Multiple Plots Plot Formatting Homework.
COMPREHENSIVE Excel Tutorial 4 Working with Charts and Graphics.
Lecture 9 Plotting in 2-D Plotting in 2-D, Plotting Multiple Curves, Plotting with Figures, Plot Settings, Scaling, Legends © 2007 Daniel Valentine. All.
Plotting. Basic Plotting Two vectors of x and y values needed. Vectors need to be of the same length, but not necessarily of the same geometry. For example,
Using Charts in a Presentation Lesson 6. Software Orientation Charts can help your audience understand relationships among numerical values. The figure.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
An introduction to Plotting in MATLAB Rikard Johansson Department of Biomedical Engineering (IMT) Linköping University
Instructor: Professor Cora Martinez, PhD Department of Civil and Environmental Engineering Florida International University.
© 2002 ComputerPREP, Inc. All rights reserved. Word 2000: Working with Long Documents.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
Make the Main Title with Large Bold Type Your Name and Title Here Your Department Here Texas A&M Health Science Center Make the Main Title with Large Bold.
XP New Perspectives on Microsoft Access 2002 Tutorial 51 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 1 in MATLAB Topics Covered: 1.Plotting basic 2-D plots The plot()
„  1999 BG Mobasseri1 9/18/2015 June 2 GRAPHICS IN MATLAB- PART I BASIC PLOTTING.
A short intermission about function handles and cell arrays A MATLAB function may be referenced by a handle. >> sphere(100)
Matlab tutorial course Lesson 5: Loading and writing data, producing visual output
CTS130 Spreadsheet Lesson 9 - Building Charts. What is a Chart? A chart is a visual display of information in a worksheet. Charts can help you make comparisons,
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Return to Outline Copyright © 2011 by Maribeth H. Price 3-1 Labeling and annotation.
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB – 2D Plots 1 Go to the class drive: ---> MatLab - Graphing ---> Seed Files.
Barak Shenhav Early Evolution Course 11 Feb 2001 MATLAB Visualization, Functions & Debugging.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
Introduction to Engineering MATLAB – 9 Plotting - 2 Agenda Formatting plots.
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
Figures & Axes, Printing & Saving. Outline Announcements –Homework I on web, due Wed. 5PM by –No lecture on Fri. 10/26, rescheduled to Wed. 10/31.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Lab 2 : potting to Matlab Networks.
An Introduction to Programming in Matlab Emily Blumenthal
Figures & Axes, Printing & Saving. Outline Announcements –Homework I on web, due Wed. 5PM by e- mail A word on HWI and cookies What happens when you plot.
EGR 106 – Week 5 – 2-D Plots Question : Why do engineers use plots? Answer : To analyze, visualize, and present data. Matlab has many useful plotting options.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Prof. N. P. Jadhav Presented by. Overview of MATLAB environment MATLAB is an interactive, matrix-based system for scientific and engineering numeric computation.
Creating a Plot The plot function can take one or more inputs; e.g. plot (x, y) or plot (y) Note that in the two-argument version, the vectors x and.
Computer Application in Engineering Design
Plotting Chapter 5.
Lecture 25.
Excel Part 4 Working with Charts and Graphics
Ch3 Graphics Overview of Plotting Editing Plots
Course Information Do not rely on color to distinguish curves (due to black-white printout). Use different line styles to distinguish curves (solid, dashed,
Lecture 25: Exploring data
Excel Part 4 Working with Charts and Graphics
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files) Double click this icon
Plotting Multiple Graphs In The Same Plot
MATLAB How to use (using M-files)
Plotting Signals in MATLAB
Introduction to Matlab
Excel Part 4 Working with Charts and Graphics
Welcome To Microsoft Word 2016
Presentation transcript:

PLOTS AND FIGURES DAVID COOPER SUMMER 2014

Plots One of the primary uses for MATLAB is to be able to create publication quality figures from you data >> x = 1:.01:10; >> y = sin(x); >> plot(x,y) This will open up a new window in MATLAB titled Figure 1 that contains the plot of x and y Many of the plot parameters can be directly controlled from this window, but they reset each time a new plot is made.

Types of Plots There are a number of different plot types available within MATLAB plot() is the basic type and simply will match the first variable and the second variable must either be a scalar or a vector >> plot(x,y) plotyy() functions just like the basic plot but allows for two separate y axis to be used >> plotyy(x1,y1,x2,y2) To plot 3 dimensional graphs use either plot3() for 3 vector plot or imagesc() for easy visualization of a matrix >> plot3(x,y,z) >> imagesc(A) For bar graphs use the bar() function >> bar(x,y)

Line Style Once you have plotted a line you may want to customize them Under the line series properties there are a number of different options that can be included in the call of plot >> plot(x, y, ’LineWidth’, 2) >> plot(x, y, ‘ro’) These options always follow the style plot(…,‘Property’, value) and are used inside the call command For instance different line styles are customized using ‘LineStyle’ and then one of these specifiers SpecifierLine Style '-'Solid line (default) '--'Dashed line ':'Dotted line '-.'Dash-dot line 'none'No line

Markers You can also change the marker to any of the shapes described in the table below To specify which one you want to use either place the symbol in ‘’ directly after the x and y call in plot or use ‘Marker’, ‘’ inside the plot call SpecifierMarker Type '+'Plus sign 'o'Circle '*'Asterisk '.'Point 'x'Cross 'square' or 's'Square 'diamond' or 'd'Diamond '^'Upward-pointing triangle 'v'Downward-pointing triangle '>'Right-pointing triangle '<'Left-pointing triangle 'pentagram' or 'p'Five-pointed star (pentagram) 'hexagram' or 'h'''Six-pointed star (hexagram) 'none'No marker (default) Markers have a face, an edge, and a size all of which can be customized

Colors

In choosing colors you want to avoid picking colors close to each other on the color wheel Since the colors must be specified in R G B value you may want to use a paint editor or a color table to look up the value. Remember MATLAB works from 0 to 1 so normalize the table before you enter in the values For plot types with color as one of the axes use colormap() to set the type of colormap

Adding Text Adding text to the plot window is useful for creating legends and providing additional information Text is added with the text() function and requires at least an x and y position as well as some text >> text(x, y, ‘Hello World’) Text can have its own separate properties added to it such as font size, alignment, and color Changing the ‘HorizontalAlignment’ property will affect where in relation to the x and y provided the text will appear To display non string variables in your plots they must first be converted to strings. For numbers use the num2str() function >> text(x, y, [‘the x position is ‘, num2str(x), ‘ and the y position is ‘, num2str(y)])

New Figure Figures create the framework for any plotted image In order to create a new graphics object the figure command can be used >> figure(FigureProperties) >> h = figure When you create a figure you can also include figure properties that control. For an entire list of available properties check out the help files. The default figure handle (the variable that functions as the figure identifier) is gcf if you want to set figure properties after creating it >> set(gcf,’visible’,’off’)

Subplots Subplots allow you to add multiple figure axes to a figure. >> subplot(m,n,p) Each subplot creates a brand new plot axis which you can add plots to Subplots divide the figure window as if it was a mxn matrix. p controls which of the sections your axis exist in Overlapping subplots will cause only the final one to appear

Hold If you want to plot more than one graph on the same axes you need to use the hold command. Hold is toggled on and off using the following syntax >> hold on >> plot(x,y) >> plot(2*x,y/2) >> hold off In between the holds any plot will be added to the current figure axis If you are using subplots you should turn off the hold before plotting on the new axis

Position Instead of using the m,n,p call for subplot you can also set the position more precisely with the ‘Position’ parameter >> subplot('Position',[xpos ypos xsize ysize]) The x and y position is always the bottom left corner of the figure window and positive x is to the right while positive y is to the left The position ranges from 0 to 1

Axes Parameters Just like plots and figures axes have parameters that you may want to customize MATLAB keeps in reserve the variable gca to specify the current axis that you are on. To add axes properties to an existing axis use the command set >> set(gca, ’box’, ’on’, ’Fontsize’, 8) Axes parameters control both the style and look of the axes as well as things like tick marks and spacing >> set(gca, ’xtick’, [0:2:10], ‘XAxisLocation’, ‘top’)

Axis Controls Often MATLAB’s predetermined viewing window is not ideal for the figure that you have in mind To control the viewing position of the current axes use the axis() function >> axis([xstart xend ystart yend]) Used in combination with the ‘xtick’ and ‘ytick’ axes properties will allow for better looking axis You can also turn off all axis lines tick marks and labels by entering the following >> axis off

Labels Labels and titles allow for strings to be added as axis labels All three work very similarly >> title(‘My plot’) >> xlabel(‘Time (s)’) >> ylabel(‘Frequency \lambda’) In addition to any string the properties of labels and title can be set using the text properties list Just like every other component labels and titles should be added before moving on to the next subplot

Special Characters In all of the text fields in a plot you may come across symbols and characters that you want to add Greek letters can be added with ‘\’ in front of the phonetical spelling >> text(x, y, ‘mu is added like this \mu’ To add truncated numbers use sprintf() to first turn the number into a string >> myVal = sprintf(‘%0.2f’, pi) ans = 3.14 Superscript and subscript are ‘^’ and ‘_’. The subscript and superscript only will appear in the figure and will look normal in any string

Saving Images In order to save your figure as an image file you must use the print() function >> print(‘filename’, ’-dtiff’, ‘-r300’) There are several different file extensions including most of the standard image formats such as jpeg, gif, and bmp. All image specifications have a ‘-d ’ in front of the filetype For publication quality figures I use either tiff files (‘ -dtiff ’) or pdf files (‘ -dpdf ’) The resolution can also be specified with ‘ -r ’ ALWAYS view your figures as the saved image never with the Figure window for publication