PLOTTING AND GRAPHICS OPTIONS IN MATHEMATICA

Similar documents
Petrel TIPS&TRICKS from SCM

Microsoft Excel 2010 Charts and Graphs

Double Integrals in Polar Coordinates

Math 1B, lecture 5: area and volume

Imaging Systems Laboratory II. Laboratory 4: Basic Lens Design in OSLO April 2 & 4, 2002

CATIA Wireframe & Surfaces TABLE OF CONTENTS

The following is an overview of lessons included in the tutorial.

LESSON 7: IMPORTING AND VECTORIZING A BITMAP IMAGE

Excel Tutorial. Bio 150B Excel Tutorial 1

The small increase in x is. and the corresponding increase in y is. Therefore

Grade level: secondary Subject: mathematics Time required: 45 to 90 minutes

9.4. The Scalar Product. Introduction. Prerequisites. Learning Style. Learning Outcomes

Introduction to the TI-Nspire CX

Paper 1. Calculator not allowed. Mathematics test. First name. Last name. School. Remember KEY STAGE 3 TIER 4 6

G C.3 Construct the inscribed and circumscribed circles of a triangle, and prove properties of angles for a quadrilateral inscribed in a circle.

Lecture 2 Mathcad Basics

5 Systems of Equations

Lesson 26: Reflection & Mirror Diagrams

Introduction to CATIA V5

2 Session Two - Complex Numbers and Vectors

x 2 + y 2 = 1 y 1 = x 2 + 2x y = x 2 + 2x + 1

Pro/ENGINEER Wildfire 4.0 Basic Design

GRAPHING IN POLAR COORDINATES SYMMETRY

Elements of a graph. Click on the links below to jump directly to the relevant section

To draw a line. To create a construction line by specifying two points

7 Relations and Functions

Creating Charts in Microsoft Excel A supplement to Chapter 5 of Quantitative Approaches in Business Studies

Essay 5 Tutorial for a Three-Dimensional Heat Conduction Problem Using ANSYS Workbench

Excel -- Creating Charts

Figure 1.1 Vector A and Vector F

Datum > Curve KIM,ME,NIU

Reflection and Refraction

Lecture 8 : Coordinate Geometry. The coordinate plane The points on a line can be referenced if we choose an origin and a unit of 20

0 Introduction to Data Analysis Using an Excel Spreadsheet

PLOTTING DATA AND INTERPRETING GRAPHS

CONSTRUCTING SINGLE-SUBJECT REVERSAL DESIGN GRAPHS USING MICROSOFT WORD : A COMPREHENSIVE TUTORIAL

Geometry Notes PERIMETER AND AREA

Instructions. Information. Advice

Laser Cutter User Manual

Section 7.2 Area. The Area of Rectangles and Triangles

Area of Similar Figures PRIZM WORKSHEET #105

Sketcher. Preface What's New? Getting Started Basic Tasks Customizing Workbench Description Glossary Index

MET 306. Activity 8a. Mechanism Design Creo 2.0 Level 7 POINT A GROUND LINK LINK 1 LINK 2 LINK 3 POINT B 10/15/2010 1

CATIA Functional Tolerancing & Annotation TABLE OF CONTENTS

Geometry Notes VOLUME AND SURFACE AREA

Curve Fitting, Loglog Plots, and Semilog Plots 1

Draw pie charts in Excel

By Clicking on the Worksheet you are in an active Math Region. In order to insert a text region either go to INSERT -TEXT REGION or simply

Geometric Optics Converging Lenses and Mirrors Physics Lab IV

USING EXCEL ON THE COMPUTER TO FIND THE MEAN AND STANDARD DEVIATION AND TO DO LINEAR REGRESSION ANALYSIS AND GRAPHING TABLE OF CONTENTS

2. Select Point B and rotate it by 15 degrees. A new Point B' appears. 3. Drag each of the three points in turn.

ME Week 11 Introduction to Dynamic Simulation

Updates to Graphing with Excel

Introduction to Microsoft Excel 2007/2010

521493S Computer Graphics. Exercise 2 & course schedule change

Fireworks CS4 Tutorial Part 1: Intro

The purposes of this experiment are to test Faraday's Law qualitatively and to test Lenz's Law.

SolidWorks Implementation Guides. Sketching Concepts

Physics 235 Chapter 1. Chapter 1 Matrices, Vectors, and Vector Calculus

Microsoft Mathematics for Educators:

Graphing Quadratic Functions

Scientific Graphing in Excel 2010

Beas Inventory location management. Version

Freehand Sketching. Sections

Kristen Kachurek. Circumference, Perimeter, and Area Grades Day lesson plan. Technology and Manipulatives used:

Managerial Economics Prof. Trupti Mishra S.J.M. School of Management Indian Institute of Technology, Bombay. Lecture - 13 Consumer Behaviour (Contd )

1. Kyle stacks 30 sheets of paper as shown to the right. Each sheet weighs about 5 g. How can you find the weight of the whole stack?

Representation of functions as power series

Volumes of Revolution

Tutorial 1: The Freehand Tools

3D Drawing. Single Point Perspective with Diminishing Spaces

Please Excuse My Dear Aunt Sally

The Force Table Vector Addition and Resolution

Concepts Sectors, arcs, circumference, areas of circles and properties of cones.

Activity Set 4. Trainer Guide

Chapter 8 Geometry We will discuss following concepts in this chapter.

Understand the Sketcher workbench of CATIA V5.

Investigating Parametric Curves with MATLAB

Problem of the Month: Cutting a Cube

Shape Dictionary YR to Y6

Physics 201 Homework 8

Beginner s Matlab Tutorial

Basic Shapes. Most paintings can be broken down into basic shapes. See how this famous painting by Cézanne can be broken down into basic shapes.

1. The volume of the object below is 186 cm 3. Calculate the Length of x. (a) 3.1 cm (b) 2.5 cm (c) 1.75 cm (d) 1.25 cm

Solutions to Homework 10

TWO-DIMENSIONAL TRANSFORMATION

Basic 3D reconstruction in Imaris 7.6.1

Creating a 2D Geometry Model

Exam 1 Sample Question SOLUTIONS. y = 2x

Surface Area Quick Review: CH 5

Radius Compensation G40, G41, & G42 (cutter radius compensation for machining centers, tool nose radius compensation for turning centers)

Formulas, Functions and Charts

5. Correlation. Open HeightWeight.sav. Take a moment to review the data file.

The Fourth International DERIVE-TI92/89 Conference Liverpool, U.K., July Derive 5: The Easiest... Just Got Better!

Petrel TIPS&TRICKS from SCM

3D Drawing. Single Point Perspective with Diminishing Spaces

Publisher 2010 Cheat Sheet

2. A tutorial on notebooks

The Math Circle, Spring 2004

Additional Topics in Math

Transcription:

PLOTTING AND GRAPHICS OPTIONS IN MATHEMATICA In addition to being a powerful programming tool, Mathematica allows a wide array of plotting and graphing options. We will look at a variety of these, starting with the Plot command. The examples shown below merely scratch the surface of what you can do with Mathematica. I urge you to use the online Documentation Center (Doc Center as I refer to it throughout the write up) to see the range of possibilities with some very nice examples. This is intended to get you started; the best way to learn is through trial and error. The Plot Command We have already encountered some very simple versions of this. You have already learned how to plot several functions on a single graph : Plot x, x^2, x^3, x^4, x, -1, 1 - - - - This plots the curves x, x 2, x 3, and x 4 between -1 and 1 on the same set of axes. There are probably hundreds of options and styles we can apply to customize our diagram. The best way to learn about the various ways is to look up Plot in the online documentation center and then try out as many of the options as you can. Make sure you also click on PlotStyle and see the range of choices that gives you. For instance,

2 Plotting.nb suppose we want to customize the graph above by making the x curve a red line, x 2 curve a dashed line, the x 3 curve an orange line, and the x 4 curve a thick line, we would input: Plot x, x^2, x^3, x^4, x, -1, 1, PlotStyle Æ Red, Dashed, Orange, Thick - - - - And now we can readily tell one graph from another. In the PlotStyle command above, be aware of the following : The P and S are capitalized, so make sure you write PlotStyle In order to draw the arrow, your keystrokes should be the minus sign followed immediately (no space) by the greater than key. The first keystroke after inputting these ( -> ) will generate the arrow you see. Notice that the styles Red, Dashed, Orange, Thick all start with capital letters, and the list of commands is contained in braces. Suppose in the graph above that we want to change the color of the x 4 curve to purple (but keep the thickness of the line), we can nest commands: Plot x, x^2, x^3, x^4, x, -1, 1, PlotStyle Æ Red, Dashed, Orange, Thick, Purple - - - -

Plotting.nb 3 So the fourth command is nested; if we want a thick, dashed, purple line, we can : Plot x, x^2, x^3, x^4, x, -1, 1, PlotStyle Æ Red, Dashed, Orange, Thick, Dashed, Purple - - - and you get the idea. - AspectRatio Let' s plot a circle of radius one; I will do this by plotting on the same axes the two solutions to the equation : x 2 + y 2 = 1 fl y = 1 - x 2 Plot Sqrt 1 - x^2, -Sqrt 1 - x^2, x, -1, 1 - - - - Now, you know this is supposed to be a circle. It just doesn' t look much like one. But before you conclude either I or Mathematica have messed up, look carefully at this curve; this curve goes through the points (1, 0), (0, 1), (-1, 0) and (0, -1), just as a circle does. So why does it look like an ellipse? The reason is that Mathematica' s plotting program assumes that the ratio of width to height is equal to 1/the golden ratio. If we want to plot this to look like a circle, we input :

4 Plotting.nb Plot Sqrt 1 - x^2, -Sqrt 1 - x^2, x, -1, 1, AspectRatio Æ Automatic - - - voila. - Or, we can use the AspectRatio command to make an even more oblate shape (but the figure is still a circle): Plot Sqrt 1 - x^2, -Sqrt 1 - x^2, x, -1, 1, AspectRatio Æ 1 3 - - - - Axes or no Axes : Mathematica assumes you want axes : Plot x^2, x, -1, 1 0.8 0.6 0.4 0.2 - -

Plotting.nb 5 But if you don' t : Plot x^2, x, -1, 1, Axes Æ False Filling Let' s consider the graph of cos x : Plot Cos x, x, -p, p, Filling Æ Top Plot Cos x, x, -p, p, Filling Æ Bottom

6 Plotting.nb Plot Cos x, x, -p, p, Filling Æ Axis Let' s say you are writing a book on multivariable calculus and want to show the region defined between the curves sin x and cos x : Plot Sin x, Cos x, x, -p, p, Filling Æ 1 Æ 2 Labeling Axes and Plots : The first plot, with axes labelled : Plot x, x^2, x^3, x^4, x, 1, 1, AxesLabel x, y y - - x - -

Plotting.nb 7 Now with axes labelled and a plot label : Plot x, x^2, x^3, x^4, x, 1, 1, AxesLabel x, y, PlotLabel "Graph of powers of x" Graph of powers of x y - - x - - Notice that text is put within quotes. Or to really jazz it up (this is an example on the Mathematica website) : Plot x, x^2, x^3, x^4, x, 1, 1, AxesLabel x, y, PlotLabel Style Framed "Graph of powers of x", Blue, Background Lighter Yellow Graph of powers of x y - - x - - As you will see from even a cursory glance at the Doc Center, there are many, many ways you can spruce up your graphs. Now onto other topics. PolarPlot All of the functions we plotted above were written in Cartesian coordinates. Mathematica allows us to plot graphs using plane polar coordinates. (Read PolarPlot on the Doc Center). We could plot a circle of radius 1 by :

8 Plotting.nb PolarPlot 1,, 0,2 - - - - What does the curve r = 2 a cos q look like? PolarPlot 2 Cos,, 0,2 1.5 2.0 - - Or the curve r 2 = a 2 cos 2q (for a=2): PolarPlot 2 Sqrt Cos 2,, 0,2 0.6 0.4 0.2-2 -1-0.2 1 2-0.4-0.6

Plotting.nb 9 Plotting in 3 Dimensions : To plot a function z = f (x, y) : Plot3D Sqrt x^2 y^2, x, 1, 1, y, 1, 1 Some options : Plot3D Sqrt x^2 y^2, x, 1, 1, y, 1, 1, Mesh None

10 Plotting.nb Plot3D Sqrt x^2 y^2, x, 1, 1, y, 1, 1, Axes False Plot3D Sqrt x^2 y^2, x, 1, 1, y, 1, 1, Filling Bottom

Plotting.nb 11 Plot3D Sqrt x^2 y^2, x, 1, 1, y, 1, 1, Filling Bottom, FillingStyle Orange SphericalPlot3D To plot in three dimensional spherical coordinates, use the SphericalPlot3D command. It will take a function of r, q, f and plot it in spherical coordinates. First, a sphere of radius 1 is plotted as : SphericalPlot3D[1, {q, 0, p}, {f, 0, 2 p}]

12 Plotting.nb The two sets of braces mean you are plotting over the polar angle, q, from 0 to p, and over the azimuthal angle, f, from 0 to 2p. We can peer into the sphere by plotting over only 270 degrees of azimuth.

Plotting.nb 13 SphericalPlot3D 1,, 0,,, 0,3 2 For all you chemists out there:we plot one of the d orbitals :

14 Plotting.nb SphericalPlot3D Sin Cos Sin,, 0,,, 0,2 And another d orbital :

Plotting.nb 15 SphericalPlot3D Sin 2 Cos 2 Sin 2,, 0,,, 0,2 The Show Command Suppose we want to plot two different types of plots on the same set of axes; for instance suppose we want to overlay the plots of y = x 2 and r = cos q. Show Plot x^2, x, 0, 1, PolarPlot Cos,, 0,2 0.8 0.6 0.4 0.2 0.2 0.4 0.6 0.8 We use the Show command to combine two different sets of graphics. Look what happens when we add the PlotRange option :

16 Plotting.nb Show Plot x^2, x, 0, 1, PolarPlot Cos,, 0,2, PlotRange All 0.8 0.6 0.4 0.2-0.2 0.2 0.4 0.6 0.8-0.4 And remembering the AspectRatio issue : Show Plot x^2, x, 0, 1, PolarPlot Cos,, 0,2, PlotRange All, AspectRatio Automatic 0.8 0.6 0.4 0.2 0.2 0.4 0.6 0.8-0.2-0.4 and our plot looks like a circle as we expect.

Plotting.nb 17 Graphics Just as the Plot and PlotStyle commands give you incredible sets of options for processing plots, the Graphics command allows you to draw almost any figure you wish. Almost any figure, now matter how complicated, can be constructed by combining different primitives. A primitive is a basic geometric form, like circle, line, point, and so on (look up Graphics on the Doc Center for much, much more). Let's show how Graphics works with a few examples. Suppose I want to draw a line from (0,0) to (3,2); and on the same diagram a line from (0,0) to (-1,1). We input: g1 Graphics Line 0, 0, 3, 2 ; g2 Graphics Line 0, 0, 1, 1 ; Show g1, g2 Notice that we define each Graphics statement, and use the Show command to display both statements. The semicolons at the end of each line keeps the lines from being displayed individually. Notice also the structure of the command; we first call Graphics; the we call Line. The elements of Line are the coordinate positions of the beginning and endpoints. Be sure you recognize why there are nested braces inside the Line command. Each coordinate position represents a set of numbers, so is written in braces as {0, 0}. However, by defining two points, we have a set of sets, so we use braces to designate the set of sets, leading to the construction : Line[{{0, 0}, {3, 2}}]. We can also add directives to Graphics commands; for instance:

18 Plotting.nb Graphics Red, Thick, Dashed, Line 0, 0, 1, 1 If we want intersecting lines, we could either define two lines and us the Show command, or put two lines into one Graphics command : Graphics Red, Thick, Dashed, Line 0, 0, 1, 1, Line 0, 1, 1, 0 There are countless ways to construct graphs. My suggestion is that you try to learn the way I did; by starting with simple diagrams and building them up. I profited greatly by using the online documentation center. To show you just some of what is possible, here is the code (and output) I wrote for a very common physics situation, the force diagram for a block on a plane :

Plotting.nb 19 g1 Graphics Line 0, 0, 20, 0 ; g2 Graphics Line 0, 0, 15, 15 ; g3 Graphics Opacity 0.2, Blue, Rotate Rectangle 8, 8, 12, 12, 45 Degree, Left, Bottom ; g4 Graphics Blue, Thickness 0.01, Arrow 8, 10.8, 8, 2.8 ; g5 Graphics Cyan, Thickness 0.01, Arrow 8, 10.8, 3.8, 15 ; g6 Graphics Orange, Thickness 0.01, Arrow 2.4, 5.2, 6.6, 9.4 ; g7 Graphics Text StyleForm "Weight", FontSize 14, FontWeight "Bold", 9, 6.8, 0, 1, 0, 1 ; g8 Graphics Text StyleForm "Normal", FontSize 14, FontWeight "Bold", 6, 13, 0, 1, 1, 1 ; g9 Graphics Text StyleForm "Friction", FontSize 14, FontWeight "Bold", 4.5, 7.2, 0, 1, 1, 1 ; Show g1, g2, g3, g4, g5, g6, g7, g8, g9