Plotting – 3-Dimensional. 3D Plots versus 2D Plots 3-dimensional plots, in contrast to 2-dimensional ones, has a third axis (often called the z-axis).

Slides:



Advertisements
Similar presentations
Introduction to Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Advertisements

Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Chapter 11 Above: Principal contraction rates calculated from GPS velocities. Visualized using MATLAB.
1. Overview 2. plot in 2D 3. Plot in 3D 4. Other possible charts 5. Engineers: label your plots! 6. Plots & Polynomial Plotting 11.
Coordinates and Design.  What numbers would you write on this line?  Each space is 1 unit 0.
Chapter 7: Vectors and the Geometry of Space
Origin: The point of intersection of the x and y axes.
Fall 2006AE6382 Design Computing1 Three Dimensional Plotting Learning Objectives –Understand the anatomy of a 3D plot –Basics of constructing plots in.
MATLAB Week 3 17 November Outline Graphics – Basic plotting – Editing plots from GUI – Editing plots from m-file – Advanced plotting commands.
Objective 1 Interpret graphs. Slide Linear Equations in Two Variables; The Rectangular Coordinate System.
Ordered Pairs and the Coordinate Graph
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Plotting - Advanced. FPLOT Plots a function f(x) written as a string within quotation marks. The free variable needs to be designated with x. The lower.
Plotting 1.Overview 2.plot in 2D 3.Plot in 3D 4.Other possible charts 5.Engineers: label your plots! 6.Plots & Polynomial.
Vectors and the Geometry of Space 9. Functions and Surfaces 9.6.
 1999 BG Mobasseri1 8/29/2015 MATLAB GRAPHICS - PART II ADVANCED PLOTTING June 4, ‘99.
PLOTS AND FIGURES DAVID COOPER SUMMER Plots One of the primary uses for MATLAB is to be able to create publication quality figures from you data.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 1 in MATLAB Topics Covered: 1.Plotting basic 2-D plots The plot()
Copyright - Planchard 2012 History of Engineering Graphics Stephen H. Simmons TDR 200.
CMPS 1371 Introduction to Computing for Engineers PLOTTING.
MATLAB Plotting With MATLAB 1. Two Dimensional Plots The xy plot is the most commonly used plot by engineers The independent variable is usually called.
Equations of Lines Chapter 8 Sections
ENTC 1110 OBLIQUE PICTORIALS.
Acute angle An angle with a measure less than 90 degrees.
Vectors and the Geometry of Space 9. Three-Dimensional Coordinate Systems 9.1.
The Hong Kong Polytechnic University Industrial Centre 1 MatLAB Lesson 4 : Polynomial Edward Cheung Room W311g 2008.
MATLAB for Engineers, by Holly Moore. ISBN © 2007 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
PRE-ALGEBRA. Lesson 1-10 Warm-Up PRE-ALGEBRA Lesson 1-10 Warm-Up.
Introduction to MATLAB Session 5 Simopekka Vänskä, THL 2010.
2D Routines in 3D. Outline Announcements –HW II--due Friday. 5PM HW1 & Cookie Grids & Meshes Representing f(x,y) Lines & Surfaces in 3D Survey.
Chapter 3 Section 1. Objectives 1 Copyright © 2012, 2008, 2004 Pearson Education, Inc. Linear Equations in Two Variables; The Rectangular Coordinate System.
Copyright © Cengage Learning. All rights reserved. 16 Vector Calculus.
All words need to be learned by the end of the year. 5 th Grade Math Vocabulary Words.
Numerical Analysis 3D Plots. A numerical method is a technique for computing a numerical approximation of the solution to a mathematical problem.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
Recap Plots with More than one Line Plots of Complex Arrays Line, Color and Mark Style Axis Scaling and Annotating Plots Subplots Polar Plots Logarithmic.
ELG 3120 Lab 2 TAs Wei Zhang Ozgur Ekici (Section A) (Section B)
Projection  If straight lines are drawn from various points on the contour of an object to meet a plane, the object is said to be projected on that plane.
REVIEW. To graph ordered pairs (x,y), we need two number lines, one for each variable. The two number lines are drawn as shown below. The horizontal number.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
EGR 115 Introduction to Computing for Engineers Complex Numbers & 3D Plots – Part 2 Friday 07 Nov 2014 EGR 115 Introduction to Computing for Engineers.
GRAPHICS AND VISUALISATION WITH MATLAB UNIVERSITY OF SHEFFIELD CiCS DEPARTMENT Deniz Savas & Mike Griffiths May 2015.
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
Scatter Plots. Graphing Basics Coordinate Plane – Two real number lines that intersect at a right angle.
Honors Geometry.  We learned how to set up a polygon / vertex matrix  We learned how to add matrices  We learned how to multiply matrices.
Vectors and the Geometry of Space Section 10.4 Lines and Planes in Space 2015.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
More Matlab Graphics and GUI Graphics subplots some useful commands 3D graphics GUI GUI controls The callback property Other essential properties.
Vocabulary for the Common Core Sixth Grade.  base: The side of a polygon that is perpendicular to the altitude or height. Base of this triangle Height.
UNIT 11: 3D AutoCAD Objectives: How to print or plot a drawing How to setup a layout using title blocks and viewports Create and manage new layouts Be.
EEE 242 Computer Tools for Electrical Engineering
Lecture 17 More Plotting Chapter 12 Matrices. Outline from Chapter D Plotting 11.4 Surface Plots 11.5 Interacting with Plotted Data.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
CS112 Scientific Computation Department of Computer Science Wellesley College Kodak moments 3-D Visualization and Color.
CS112 Scientific Computation Department of Computer Science Wellesley College Kodak moments 3-D Visualization and Color.
Introduction to Functions of Several Variables
ENEE222 Elements of Discrete Signal Analysis Lab 11 1.
Plotting Chapter 5.
3D-Graphs A 3D surface is defined as: z = f(x, y)
Ch3 Graphics Overview of Plotting Editing Plots
Lecture 25: Exploring data
2D Routines in 3D.
MatLab – 2D Plots 2 MATLAB has many built-in functions and commands to create various types of plots. Instructor notes: We start with an example of some.
CSCI N317 Computation for Scientific Applications Unit 1 – 5 MATLAB
Yang-Ming University, Taipei, Taiwan
Plotting Signals in MATLAB
ORTHOGRAPHIC PROJECTION
Orthographic Projection
ORTHOGRAPHIC PROJECTION
Presentation transcript:

Plotting – 3-Dimensional

3D Plots versus 2D Plots 3-dimensional plots, in contrast to 2-dimensional ones, has a third axis (often called the z-axis). We plot both 2D and 3D charts on a flat surface (screen, paper, etc.). In 3D charts, the third dimension gives the visual impression of depth.

One dimensional data One dimensional data (a single vector) can be plotted either in 2D or 3D.

One dimensional data cont= {'Asia', 'Europe', 'Africa', 'N.America', 'S.America'}; pop= [3332; 696; 694; 437; 307]; ti= 'World population 1992'; pie(pop, cont); title(ti); figure; pie3(pop, cont); title(ti);

One dimensional data pop= [3332; 696; 694; 437; 307]; subplot(2,2,1); bar(pop); subplot(2,2,2); bar3(pop); subplot(2,2,3); barh(pop); subplot(2,2,4); bar3h(pop);

Two dimensional data Two dimensional data (a pair of vectors, typically in the form y= f (x)) can be plotted either in 2D or 3D. Plotting multiple vector pairs is also possible, such as y1= f (x), y2= g (x), y3= h (x) Each pair is usually plotted with a different color for easy discriminitation.

Two dimensional data x= linspace(0, 6*pi, 200); y1= sin(x); y2= cos(x); y3= 0.5*sin(x).*sin(12*x); plot(x,y1, x,y2, x,y3); legend('sin(x)', 'cos(x)', 'sin(x)sin(12x)/2'); figure; % 3D ribbon plot with 0.4 ribbon thickness ribbon(x', [y1',y2',y3'], 0.4); legend('sin(x)', 'cos(x)', 'sin(x)sin(12x)/2');

3D graph viewpoint The angle from which an observer sees a 3D plot can be adjusted using the VIEW function. view(azimuth, elevation) Azimuth is the horizontal rotation, and elevation is the vertical angle from the x-y plane (both in degrees). Azimuth revolves about the z-axis, with positive values indicating counter-clockwise rotation of the viewpoint. Positive values of elevation correspond to moving above the object; negative values move below.

View command formats Different ways to use the view command: Most used: view(azimuth, elevation) Look at the plot from the angle of a point in cartesian space: view([x, y, z]) Default 3D view (azimuth: -37.5°, elevation: 30°): view(3) Convert to 2D view (look from the top): view(2)

View command examples view(100,15)view([5,5,5]) view(3)view(2)

Three dimensional data We almost always need to use a 3D chart to represent three dimensional data. Three dimensional data is often available in one of two formats:  Three vectors, each holding x, y, and z components of points which, when interconnected, form a trajectory (path) in space  Three matrices, each holding x, y, and z components of points which, when interconnected, form a surface in space

Trajectory plots in 3D Trajectory plots in 3D are based on three vectors. They are generally characterized by one free and two dependent, or no free and three dependent vectors. [y, z]= f (x) or [x, y, z]= g (t)

Trajectory plots in 3D z= linspace(0,4,1000); x= z.*cos(exp(z)); y= z.*sin(exp(z)); plot3(x,y,z,'r') grid on

Trajectory plots in 3D t= linspace(0,10,4000); z= -sin(t); y= sqrt(1-z.^2).*cos(20*t); x= sqrt(1-z.^2).*sin(20*t); comet3(x,y,z)

Surface plots in 3D Surface plots are based on three matrices. They are generally characterized by two independent (free) matrices and one dependent matrix. Z= f (X, Y) The independent matrices generally contain a rectangular grid of coordinates on the X-Y plane. If we are only interested in the shape, rather than the coordinates of the surface, then we can build the plot by using only the Z matrix.

Building the X-Y grid (1) Assume that a surface chart is to be drawn in the range –2  x  2 and 2  y  8. We want data to be plotted for all integer x in the range, and only even numbers in y. This implies a rectangular grid whose x-coordinates are [-2, -1, 0, 1, 2]. The y-coordinates of this grid are [2, 4, 6, 8].

Building the X-Y grid (2) We can represent this 4x5= 20-point grid by putting the x-coordinates of every point into a X matrix, and the corresponding y-coordinates into a Y matrix. The resulting matrices would then look like this:

Building the X-Y grid (3) A function named MESHGRID is very useful in automatically creating the X and Y matrices out of x and y vectors of the grid. x= [ ]; y= [ ]; [X,Y]= meshgrid(x, y);

Building the Z matrix Once the X-Y grid is ready, building the actual surface coordinates into a matrix is a matter of writing an equation of X and Y: Z= *X.^ *Y.^ *Y; surf(X,Y,Z)

Surface plots We often want a large number of points in the grid for seeing a better rendered surface. When x- and y-axis grids are identical, we do not need to create separate x and y vectors. % Egg carrier u= linspace(-10, 10, 50); [X,Y]= meshgrid(u, u); Z= sin(X) + sin(Y); surf(X, Y, Z)

Surface plot types Contour (contour lines where the surface crosses certain z-levels) Surf (color-filled surface patches) Mesh (displays only colored lines between Z data points) Special shapes (spheres, cylinders, fills, etc.)

PEAKS function PEAKS is a function of two variables, obtained by translating and scaling Gaussian distributions. It creates a nice looking surface, which is useful for demonstrating 3D plots such as MESH, SURF, CONTOUR, etc. For the surface charts on tnhe following slides, we will assume X, Y and Z matrices generated by the following code: u= linspace(-3, 3, 50); [X, Y]= meshgrid(u, u); Z= peaks(X, Y);

2D CONTOUR plots Contour plots are probably the only chart types that can successfully represent three dimensional data in 2D. They project the cutting points of particular z-levels onto a flat surface. The plot on the right top is a default contour plot, while the one at the bottom is a filled contour of 20 levels. contour(X, Y, Z); figure; contourf(X, Y, Z, 20);

3D CONTOUR plots 3D contour plots display contour data in their actual intersection surfaces in space. The plot on the right top is a default 3D contour plot, while the one at the bottom is a 3D contour plot of 20 levels. contour3(X, Y, Z); figure; contour3(X, Y, Z, 20); grid off

SURF plot - faceted This is the default SURF plot. Actual data points are at places where the x and y lines intersect. surf(X, Y, Z); shading('faceted');

SURF plot - flat In this SURF plot, the lines in x and y directions are removed to show only colored rectangles. surf(X, Y, Z); shading('flat');

SURF plot - interpolated In this SURF plot, the lines in x and y directions are removed, and additionally data is interpolated to display continuous colors. surf(X, Y, Z); shading(‘interp');

SURFC plot In the SURFC plot, we have the SURF plot with additional contour lines projected onto the X-Y plane. surfc(X, Y, Z);

SURFL plot In the SURFL plot, we have the SURF plot with highlights from a light source. surfl(X, Y, Z);

MESH plot MESH plots give the colored parametric mesh defined by the given matrices. mesh(X,Y,Z);

MESH plot – HIDDEN OFF MESH plots by default hide the shapes behind any drawn mesh area. To display those, you can turn the hidden mode OFF. mesh(X,Y,Z); hidden off

MESHC plot MESHC plots, in addition to the mesh plot, the contour lines projected to the X-Y plane. meshc(X,Y,Z);

MESHZ plot MESHZ plots give the colored parametric mesh defined by the given matrices. The small plot is with hidden mode turned off. meshz(X,Y,Z);

WATERFALL plot WATERFALL is similar to MESHZ, but without any lines drawn in the column direction. waterfall(X,Y,Z);

Special types: FILL and FILL3 % Five arm star, with 72° between arms for k=1:10 a= (k-1)*36; if mod(k,2)==1% arm x(k)= sin(a/180*pi); y(k)= cos(a/180*pi); else% trough x(k)= sin(a/180*pi)*0.382; y(k)= cos(a/180*pi)*0.382; end subplot(3,1,1) fill(x,y,'y'); axis('square') subplot(3,1,2) % Set color to the point’s y height fill(x,y,y); axis('square') z=y*0.5; subplot(3,1,3) fill3(x,y,z,y); axis('square')

Special types: Sphere, etc. There are ready functions for some known 3D shapes:  SPHERE  ELLIPSOID  CYLINDER [x,y,z]= ellipsoid(1,1,1,4,6,3); surfl(x,y,z); colormap copper axis equal

Advanced formatting: Handles For more advanced formatting of charts, we can obtain a handle for the plot while creating it, and modify plot properties through handle operations. All chart creation commands return handles when we assign the command to a variable. Examples: h_plot= surf(X, Y, Z); h_title= title(‘Peaks in 3D'); A get command to the handle will list all properties associated with that item. get(h_plot); get(h_title);

Advanced formatting: Handles You can see the settings associated with an item, and their present values using the GET command: >> get(h_title) BackgroundColor = none Color = [0 0 0] EdgeColor = none EraseMode = normal Editing = off Extent = [ ] FontAngle = normal FontName = Helvetica FontSize = [10] FontUnits = points FontWeight = normal HorizontalAlignment = center LineStyle = - LineWidth = [0.5] Margin = [2] Position = [ ] Rotation = [0] String = Peaks in 3D Units = data Interpreter = tex VerticalAlignment = bottom

Advanced formatting: Handles The SET command can be used to modify properties of the item associated with the handle: set(h_plot, 'LineStyle', ':'); set(h_title, 'FontSize', 16, 'FontWeight', 'bold')