Tutorial 04
2D Graphics for Continuous Functions

Copyright © 2003 by Bill Titus, Carleton College,
Department of Physics and Astronomy, Northfield, MN  55057-4025
March 1, 2003

Part 1 - Getting Started

Step 1.  Start up Mathematica and open the notebook  Tutorial04.nb.  Remember, this notebook is located in the workshop folder.

Step 2.  OPTIONAL.  Since you're going to edit this notebook, you need to make a copy of this notebook and work with that copy.  To do so, select  File / SaveAs  from the Mathematica menu and save the notebook in the workshop folder under the name  myTutorial04.nb .

Part 2 - The Problem of Interest

In this notebook, you'll solve the second part of the following problem, which is taken from Mathematics:  A Simple Tool for Geologists by David Waltham (Chapman & Hall, London, 1994, page 38).   You'll do so by having Mathematica plot   p  as a continuous function of  z .

The rate of accumulation,  p,  of carbonate sediments on a reef is given approximately by   p = (Subscript[p, 0])exp(-z/(Subscript[z, 0])),  where  (Subscript[p, 0]) and  (Subscript[z, 0])  are constants and  z  is the depth below sea level.

(i)     Calculate  p  at depths of  0.0,  2.0,  4.0,  ... , 20.0 m  if  (Subscript[p, 0]) = 3.0 m (ky^(-1)) and  (Subscript[z, 0])= 20.0 m.
(ii)    Sketch the results.
(iii)   Give an interpretation for the constants  (Subscript[p, 0])  and  (Subscript[z, 0]).

Part 3 - The Bare Plot

Topics and Skills

1.  The bare  Plot[]  command
2.  Eliminating the  -Graphics-  cell
3.  Resizing a plot area
4.  Reading out graph coordinates
5.  Multiple graphs on a single plot using one  Plot[]  command

Step 1.  Create a function   p[p0_,z0_,z_] that corresponds to the equation given in the problem stated above and then enter the results.

Comment 1

1.  Remember, in a function definition, the underscores only appear on the left hand side of the equal sign.  Also make sure the first line of your code is a  Clear[]  statement that contains the function name and all the variables you plan to use. 
2.  You can either use  =  (Set[])  or  :=  (SetDelayed[])  in your definition.  With  Set[], the code will be echoed back to the screen unless you put a semicolon after the last line.  With  SetDelayed[],  the code is never echoed back to the screen, even if there is no semicolon.

Step 2.  Check that your function works by evaluating it for  (Subscript[p, 0]) = 3.0,  (Subscript[z, 0]) = 20.0,  and  z = 2.0. You should find a value of  2.71451  for  p.

Step 3.  One way to examine the behavior of   p[p0,z0,z]   is to look at 2D plots of  p  versus  z  for different  values of  (Subscript[p, 0])  and  (Subscript[z, 0]).   Use the Mathematica help command  ?  to find information about the built-in function  Plot[]  that will allow you to create such graphs.

Step 4.  See what happens if you use two question marks before  Plot  instead of one.

Comment 4

1.  Note that the results for help (one question mark) and extended help (two question marks) differ when applied to  Plot[].  In particular, both help and extended help give the function's usage statement, i.e, an explanation of the purpose and structure of the function.  However, extended help also lists all the options that are available to the function.
2.  For now, don't worry about the options to  Plot[].  You'll see later that they allow you to jazz up your plot and make it look more professional and informative.  To start with, you'll concentrate only on the bare  Plot[]  command.

Step 5.  Activate the following cell that uses  Plot[]  to create a graph of   p[po,z0,z]  for  z  going from  0.0  to  20.0,  when  (Subscript[p, 0]) = 3.0  and  (Subscript[z, 0]) = 20.0 .

Clear[p0, z0]
p0 = 3.0;
z0 = 20.0;
Plot[p[p0, z0, z], {z, 0.0, 20.0}]

Comment 5

1.  Note that this plot just contains the "bare" features of a graph:  axes, units, and the plot itself.
2.  Technically, the plot is a side effect of the command and the cell with the word  -Graphics-  is the actual output.  However this latter cell doesn't serve much purpose here.  You can suppress this output cell by putting a semicolon after  Plot[].  Try this suggestion out by editing your old cell.
3.  You don't need to include decimal points for the numbers in the arguments of the plot command.  I usually do since it reminds me that the numbers used are not integers, but real decimal numbers.
4.  It's very easy to make mistakes with commands like  Plot[]  that have lots of parts to their arguments.  When you do make mistakes, Mathematica will respond with warning messages that may or may not make sense to you and Mathematica may or may not create a plot.

Step 6.  Retype the command in Step 5 in a cell below, but replace  z  by  x,  a mistake that could easily have resulted from a typing error.   Be sure there's a semicolon at the end of your plot command.  Activate the cell and read the warning messages that appear.

Comment 6

1.  The blue warning messages many times do not make much sense to the average user.  In this case, they're telling you that  p[p0,z0,x]  does not evaluate to a real number.  When you have some extra time, make lots of mistakes and see what the corresponding warning messages say.

Step 7.  Copy and paste the cell containing your plot code from Step 5 to a cell below and again enter the results.

Step 8.  Click inside the plot area.  You should see an outline of a box appear around the plot that has eight "handles".  Click and drag one of the handles on the right and see what happens.  Then click and drag on any point inside the box.

Comment 8

1.  When you click and drag on a box handle, the plot increases proportionally in size, but the sides of the box don't move independently.  This is because Mathematica preserves the aspect ratio (the ratio of the height to width of the plot).  Note that the default setting for the aspect ratio is  2/((Sqrt[5])+1),  which is the reciprocal of the golden ratio.
2.  When you click and drag on any point inside the box, you can translate the box around in the cell to different positions.

Step 9.  Mathematica allows you to read out coordinates in the plot region by clicking on the plot to highlight it, holding down the (apple) key, and moving the mouse without clicking.  The cursor will change to a cross and the plot coordinates of the cursor's location are then displayed in the bottom left corner of the Mathematica window.  Try this out on your plot in Step 8.

Step 10.  The  Plot[]  command allows you to plot multiple graphs on the same plot.  Suppose you want to graph  p[3.0,20.0,z]  and   p[3.0,10.0,z]  on the same plot.   You can do so with  Plot[]  by putting the list  {p[3.0,20.0,z],  p[3.0,10.0,z]}  in as  Plot[]'s  first argument.  Try this technique out in a cell below; be sure to put a semicolon after the  Plot[] command so as to eliminate the  -Graphics-  tag.

Part 4 - Options for  Plot[]

Topics and Skills

1.  The Mathematica command  Options[]
2.  The general structure of  Plot[]  options
3.  Curve options:  Compiled,  PlotPoints,  PlotDivision,  MaxBend
4.  Appearance Options
     a.	Axes:  Axes,  AxesLabel,  AxesOrigin,  AxesStyle
     b.	Frame:  Frame,  FrameStyle,  FrameLabel,  Ticks,  FrameTicks
     c.	General:  AspectRatio,  PlotLabel,  Background
            DefaultColor,  GridLines,  PlotRange,  PlotStyle
     d.	Graphics Directives:  RGBColor[],  StyleForm[],  Thickness[],  
            GrayLevel[],
5.  Atomic type:  String
6.  The Mathematica command  StringForm[]  and  PaddedForm[]
7.  The option  PlotRange->All

Step 1.   You can find out the possible options for  Plot[]  by using the Mathematica command   Options[].  But, before you do that, type in  ??Options  to get extended help on this latter function.

Comment 1

1.  OK, I didn't find the Mathematica help on this function particularly useful.  That happens.
2.  Extended help includes the information on the attributes for  Options[].  In this case,  Options[]  has the attribute  Protected,  which just means that you can't use  Options  as a name for one of your own functions.

Step 2.  Now type in   Options[Plot] and see what happens.

Comment 2

1.  The output of  Options[] is the same as the second half of extended help.
2.  The possible options are a list of rules with the structure  option -> expression.  You can read the symbol  ->  (made with a "dash" and a "greater than sign") as "goes to".  The left hand side of the structure is the name of the option and the right hand side is its setting.
3.  The options listed above all have default settings.  The mysterious word   Automatic that appears several times implies that Mathematica uses various internal algorithms to decide on the formatting for you.  For example, with the option  Axes->Automatic,  Mathematica will scale the axes on the plot as it sees fit.
4.  Options are added to the  Plot[]  command after the range specification in  Plot[]'s  argument.  Options are separated from the range specification and from one another by commas and can be specified in any order.  Don't forget the commas; if you do, Mathematica may give you some strange warning messages and may not even create your plot or, if it does, the plot may not be what you expect.
5.  There are two classes of options for  Plot[]:  those that affect the calculation of the curve, and those that enhance the overall appearance of the plot.

Step 3.  Use the  HB  to locate information on   Plot[];  in particular, find out the purpose of the four curve options:  Compiled,   MaxBend,  PlotDivisions,  and  PlotPoints.

Step 4.  As an example of the curve options, activate the code in the cell below.  Then play with the numerical values assigned to the options to see what happens.

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
Plot[p[p0, z0, z], {z, 0, 20.0}, MaxBend -> 45.0, 
        PlotPoints -> 3, PlotDivision -> 5];

Comment 4

1.  Unless your function behaves rather wildly, you usually don't have to worry about the curve options.  If you ever need to smooth out your curve, try increasing the number of  PlotPoints  first; it seems to be the one option that gives the greatest payoff.
2.  Note that I put the assignment statements for  p0  and  z0  on the same line.  You can do this as long as there is a semicolon between the statements.

Step 5.  You're now going to look at a small, but useful set of plot "appearance" options.  Activate the cell below and guess what the various options are doing.  Feel free to play with the numerical settings.

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[1, 0, 
            0], 
AxesLabel -> {"z", "p"}, 
        PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
PlotRange -> {{0.0, 
              25.0}, {0.0, 4.0}}];

Comment 5

1.  Here the options have been put on different lines for ease of readability.  This isn't necessary to do and  Mathematica is happy as long at the options are separated by commas.

Step 6.  Use the  HB  to get information on the  PlotStyle  option as well as the graphics directive  RGBColor[].  A quick way of doing this is to highlight the name of the option with the mouse, anywhere the name of the option appears, and then select  Help / Find Selected Function ...  from the Mathematica menu bar.

Step 7.  Use the information you found about  RGBColor[]  to change the color of the curve in Step 5 to blue.   Just edit the cell in Step 5; don't retype it.

Step 8.  Find out information about the option   PlotLabel  and the function  StyleForm[].  Both use another atomic type, "String",  which is just a collection of ASCII characters contained within double quotes.  Strings are used mostly for printing purposes.

Step 9.  Activate the following cells to get a feeling for some of the other options available for  Plot[].  Feel free to change any of the settings and to experiment on your own.

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[1, 0, 
            0], 
AxesLabel -> {"z", "p"}, 
        PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
AspectRatio -> 
          1, 
PlotRange -> {{0.0, 25.0}, {0.0, 
              4.0}}];

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[1, 0, 
            0], 
AxesLabel -> {"z", "p"}, 
        PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 
              12], 
AxesOrigin -> {10.0, 
            2.0}, 
PlotRange -> {{0.0, 25.0}, {0.0, 
              4.0}}];

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[1, 0, 
            0], 
AxesLabel -> {"z", "p"}, 
        PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
Axes -> {True, 
            False}, 
PlotRange -> {{0.0, 25.0}, {0.0, 
              4.0}}];

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
\(\(Plot[
        p[p0, z0, z], {z, 0, 
          20.0}, 
PlotStyle -> {RGBColor[1, 0, 0], 
            Thickness[
              0.015]}, 
AxesLabel -> {"z", "p"}, 
        PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
PlotRange -> {{0.0, 
              25.0}, {0.0, 4.0}}];\)\)

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[0, 0, 
            1], 
AxesLabel -> {"z", "p"}, 
        PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
Background -> 
          GrayLevel[
            0.8], 
PlotRange -> {{0.0, 25.0}, {0.0, 
              4.0}}];

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[0, 0, 
            1], 
AxesLabel -> {"z", "p"}, 
        PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
Background -> 
          GrayLevel[0.8], 
DefaultColor -> 
          RGBColor[1, 0, 
            0], 
PlotRange -> {{0.0, 25.0}, {0.0, 
              4.0}}];

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[0, 0, 
            1], 
AxesLabel -> {"z", "p"}, 
        PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
Background -> 
          GrayLevel[
            0.8], 
Ticks -> {Automatic, {1.0, 2.0, 
              3.0, 4.0}}, 
PlotRange -> {{0.0, 
              25.0}, {0.0, 4.0}}];

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
\(\(Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[0, 0, 1], 
Frame -> 
          True, 
FrameLabel -> {"z", "p"}, 
FrameStyle -> RGBColor[1, 0, 0], 
        PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
PlotRange -> {{0.0, 
              20.0}, {0.0, 4.0}}];\)\)

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
\(\(Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[0, 0, 1], 
Frame -> 
          True, 
FrameLabel -> {"z", "p", "Accumulation Rate vs Depth", ""}];\)\)

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
\(\(Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[0, 0, 1], 
Frame -> 
          True, 
FrameLabel -> {"z", "p", "Accumulation Rate vs Depth", ""}, 
FrameTicks -> {Automatic, {1.0, 2.0, 3.0, 
              4.0}}, 
PlotRange -> {0.0, 
            4.0}];\)\)

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
\(\(Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[0, 0, 1], 
Frame -> 
          True, 
FrameLabel -> {"z", "p", 
            StringForm["p0 = `` and  z0 = ``", p0, 
              z0], ""}, 
FrameTicks -> {Automatic, {1.0, 2.0, 3.0, 4.0}, Automatic, 
            Automatic}, 
PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
PlotRange -> {0.0, 
            4.0}];\)\)

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
\(\(Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[0, 0, 1], 
Frame -> 
          True, 
FrameLabel -> {"z", "p", 
            StringForm["p0 =`` and  z0 =``", PaddedForm[p0, {2, 2}], 
              PaddedForm[
                z0, {2, 
                  2}]], ""}, 
FrameTicks -> {Automatic, {1.0, 2.0, 3.0, 4.0}, Automatic, 
            Automatic}, 
PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
PlotRange -> {0.0, 
            4.0}];\)\)

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
\(\(Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[0, 0, 1], 
Frame -> 
          True, 
FrameLabel -> {"z", "p", 
            StringForm["p0 =`` and  z0 =``", PaddedForm[p0, {2, 2}], 
              PaddedForm[
                z0, {2, 
                  2}]], ""}, 
FrameTicks -> {Automatic, {1.0, 2.0, 3.0, 4.0}, Automatic, 
            Automatic}, 
PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
PlotRange -> {0.0, 
            4.0}];\)\)

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
\(\(Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[0, 0, 1], 
Frame -> 
          True, 
FrameLabel -> {"z", "p", 
            StringForm["p0 =`` and  z0 =``", PaddedForm[p0, {2, 2}], 
              PaddedForm[
                z0, {2, 
                  2}]], ""}, 
FrameTicks -> {Automatic, {1.0, 2.0, 3.0, 4.0}, Automatic, 
            Automatic}, 
GridLines -> 
          Automatic, 
PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
PlotRange -> {0.0, 
            4.0}];\)\)

Clear[p0, z0]
p0 = 3.0; z0 = 20.0;
\(\(Plot[
        p[p0, z0, z], {z, 0, 20.0}, 
PlotStyle -> 
          RGBColor[1, 0, 0], 
Frame -> 
          True, 
FrameLabel -> {"z", "p", 
            StringForm["p0 =`` and  z0 =``", PaddedForm[p0, {2, 2}], 
              PaddedForm[
                z0, {2, 
                  2}]], ""}, 
GridLines -> {Automatic, {1.0, 2.0, 3.0}}, 
PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", 
            FontSize -> 12], 
Background -> 
          GrayLevel[
            0.8], 
PlotRange -> {{\(-0.01\), 
              20.0}, {\(-0.01\), 4.0}}];\)\)

Comment 9

1.  Frame diagrams are quite useful and look nice.  You can get a lot of millage out of the two options,  Frame  and  FrameLabel.  As you've seen above, the latter option is a cheep way to simultaneously title your plot and label your axes.
2.  On the Mac, the vertical label on a frame diagram shown on the screen isn't rotated correctly.  However, if you print out the plot, the label is oriented correctly.
3.  The graphics directive  StringForm[]  converts symbols and numbers into strings.  The two back quote marks  ``  save the place of the variable.
4.  By default,  Mathematica decides on the plot range to use by focuses in on what it considers to be the most interesting part of the graph.  As a result, sometimes it doesn't display the graph's entire range.  If you want to see the entire range, use the option  PlotRange->All.  This is a very useful option to keep in your back pocket.

Part 5 - Multiple Plots

Topics and Skills

1.  Assigning names to plots
2.  Plotting multiple graphs on a single plot using  Show[]
3.  The strange options  DisplayFunction->Identity  and  DisplayFunction->$DisplayFunction

Step 1.  You've seen that Mathematica can produce multiple plots with a single plot command.  It can also produce multiple plots by superimposing two or more preexisting plots.  The following code produces a frame plot for  p[po,z0,z]  for  z  going from  0.0  to  20.0,  with  (Subscript[p, 0]) = 3.0  and  (Subscript[z, 0]) = 20.0.  The plot is given the name  plot1  so it can be referred to later on.  Look over the code and then activate the cell.

Clear[p0, z0, plot1]
p0 = 3.0; z0 = 20.0;
plot1 = 
        Plot[p[p0, z0, z], {z, 0, 20.0}, PlotStyle -> RGBColor[0, 0, 1], 
          Frame -> True, 
          FrameLabel -> {"z", "p", "Accumulation Rate vs Depth\
", ""}, Axes -> None];

Comment 1

1.  Note that compulsive Bill has included a  Clear[]  command at the beginning of the code that contains all the variables that are used.  This isn't necessary to do, but it does help the person reading your notebook to immediately see the variables of interest and it can sometimes prevent you from using a variable to which you have already assigned a value.

Step 2.  Use copy, paste, and edit to produce a frame plot for  p[p0,z0,z]  over the same time range as  plot1,  but now with   (Subscript[p, 0]) = 3.0  and   (Subscript[z, 0]) = 10.0 .   Give the plot the name  plot2  and have the curve plotted with a different color from the curve in  plot1.

Step 3.  Repeat Step 2, but now use  (Subscript[z, 0]) = 15.0;  use another color for the curve, and call the plot  plot3.  Remember, copy and paste can save you lots of time.

Step 4.  Find out information about the Mathematica command  Show[].  Then use  Show[]  to display  plot1,  plot2,  and  plot3 together on the same plot by activating the code below.

Show[{plot1, plot2, plot3}]

Comment 4

1.  Remember, if you don't want the cell containing the word  -Graphics-  following the plot, put a semicolon after  Show[].

Step 5.   Options placed in  Show[]  override and supplement those in the individual plots, provided they pertain to the plot as a whole.  As an example, look over the code below and then activate the cell.

Show[{plot1, plot2, plot3}, 
        FrameLabel -> {"depth", "rate"}, 
        PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", FontSize -> 12, 
            FontWeight -> "Bold"], 
        GridLines -> Automatic];

Step 6.  Suppose you didn't want the individual plots shown, but only the composite one.  To do so, you would insert the option 

			DisplayFunction -> Identity
					
in each individual plot and then the option  
 
			DisplayFunction -> $DisplayFunction
				
in  Show[].  Try this technique out by activating the cell below.

Clear[p0, z0, plot1, plot2, plot3]
p0 = 3.0;

    
z0 = 10.0;
plot1 = 
        Plot[p[p0, z0, z], {z, 0, 20.0}, PlotStyle -> RGBColor[1, 0, 0], 
          Frame -> True, Axes -> None, 
          DisplayFunction -> Identity];

    
z0 = 15.0;
plot2 = 
        Plot[p[p0, z0, z], {z, 0, 20.0}, PlotStyle -> RGBColor[0, 0, 1], 
          Frame -> True, Axes -> None, 
          DisplayFunction -> Identity];

    
z0 = 20.0;
plot3 = 
        Plot[p[p0, z0, z], {z, 0, 20.0}, PlotStyle -> RGBColor[1, 0, 1], 
          Frame -> True, Axes -> None, 
          DisplayFunction -> Identity];

    
Show[{plot1, plot2, plot3}, 
        FrameLabel -> {"depth", "rate"}, 
        PlotLabel -> 
          StyleForm["Accumulation Rate vs Depth", 
            FontFamily -> "Helvetica", FontSize -> 12, 
            FontWeight -> "Bold"], GridLines -> Automatic, 
        DisplayFunction -> $DisplayFunction];

Comment 6

1.  Note that the individual plot commands don't need some of the appearance options as they did before since the latter are included in the final  Show[]  command.

Part 6 - Some Practice

The Problem

Suppose you want to plot the gravitational field  (Subscript[g, z]) on a level surface of the earth due to the present of a spherical mass  m  a fixed distance below the surface of a homogenous region of the earth.  To do so, use a cartesian coordinate system  {x, y, z}  such that the origin is on the level surface and the z-axis of the coordinate system points vertically upward.  Assume the spherical mass is located at coordinates  {(Subscript[x, 0]), (Subscript[y, 0]), (Subscript[z, 0])}  and has a mass contrast  Δm.  The z-component of the gravitational field can then be written as

					(Subscript[g, z])[x, y, z]  = -G Δm \(\(z - 
                z\_0\)\/\((\((x - x\_0)\)\^2\  + \ \((y - y\_0)\)\^2\  + \ \((z - z\_0)\)\^2)\)\^\(5/2\)\)

Choose units such that  
\(TraditionalForm\`\(\(					\)\(g\_z\)\)\)[x, y, z]  = -Δm \(\(z - 
                z\_0\)\/\((\((x - x\_0)\)\^2\  + \ \((y - y\_0)\)\^2\  + \ \((z - z\_0)\)\^2)\)\^\(5/2\)\) ,

where distance is measured in kilometers and mass in (10^6) kilograms.  This is done so you can use the second equation without having to worry about units.

(i)     Create a function that allows you to find  (Subscript[g, z])  at any value of  {x, y, z}  for any mass contrast  Δm  that is located at any position  {(Subscript[x, 0]), (Subscript[y, 0]), (Subscript[z, 0])}.
(ii)    By varying  x,  plot  (Subscript[g, z])  over the surface at  y = 0,  z = 0  for a mass   Δm = 0.001   located at  {(Subscript[x, 0]), (Subscript[y, 0]), (Subscript[z, 0])} = {0.00,  0.00,  -0.10}.
(iii)   Produce another plot of  (Subscript[g, z])  for  y = 0,  z = 0,  but in this case have the mass have   Δm = 0.001  and be located at  {0.00,  0.00,  -0.15}.
(iv)   For comparison purposes, show the graphs you generated in parts (ii)  and  (iii)  on the same plot.
(v)    Suppose there actually two masses:  (Subscript[Δm, 1]) = 0.001  at  {0.00,  0.00,  -0.10}  and  (Subscript[Δm, 2]) = 0.003  at {0.20,  0.00,  -0.15}.  Plot the field  (Subscript[g, z])  due to the superposition of these two objects.

Step 1.  Define the most flexible Mathematica function for  (Subscript[g, z])  corresponding to the second equation given in the statement of the problem.

Step 2.  Generate the individual plots requested in part (ii) and (iii)  of the problem.

Step 3.  Superimpose your two plots from Step 2 so you can visually compare the fields produced by the two locations of the mass  Δm.  Be sure to title your plot appropriately.

Step 4.  Produce the plot asked for in part (v) in such a way that it's easy for you to change the values of the given parameters.

Part 7 - Save Your Notebook (OPTIONAL)

Step 1.  Remove all output cells from this notebook, and to do one final save of your notebook before you quit Mathematica.