Go to CCP Homepage

Go to Materials Page

Go to Linear Algebra Materials

Go to Table of Contents

Go Back One Page

Go Forward One Page

Mathematica Tutor

Part 8: Graphing Functions

  1. Let's plot 3 sin(2x) over the interval [0,2 pi]. Enter
    Plot[3*Sin[2*x], {x, 0, 2*Pi}];
    We can obtain the same result by defining the function f given by
    f(x) = 3 sin(2x)

    and plotting f(x). Enter the following:
    f[x_]:= 3*Sin[2*x]
    Plot[f[x], {x, 0, 2*Pi}];

  2. When the plot appears, use your mouse to "select" it -- you should see a box around the graphic. Experiment with the drag buttons at the corners and sides of the box.

  3. Next we plot data given as ordered pairs. Enter
    data={{0,1},{2,2},{4,6},{5,1}}
    Then enter
    ListPlot[data, PlotStyle->PointSize[.02]];
    Go back and see what happens if you delete "PlotStyle->PointSize[.02]."

  4. Often we wish to view several graphs at the same time. One way to do this is to enter the desired plots directly into the plot command. Enter
    Plot[{Sin[x],Cos[x]}, {x, 0, 2*Pi}, PlotStyle->{RGBColor[0,1,0], RGBColor[0,0,1]}];

  5. Another way to create multiple plots is to use the Show command. Enter
    graph1=Plot[Sin[x], {x, 0, 2*Pi}, PlotStyle->RGBColor[0,1,0]];
    This creates a plot and names it "graph1."

    Create a second plot by entering
    graph2=Plot[Cos[x],{x, 0, 2*Pi}, PlotStyle->RGBColor[0,0,1]];

    To see both plots together, enter
    Show[graph1,graph2];

Go to CCP Homepage

Go to Materials Page

Go to Linear Algebra Materials

Go to Table of Contents

Go Back One Page

Go Forward One Page


modules at math.duke.edu

Copyright CCP and the author(s), 1998, 1999, 2000