Supplementary Help Browser for
Mathematica Graphics
By: Ted Ersek    ted.ersek@navy.mil

ColorFunctionScaling
Converting between graphics types
DisplayString
HiddenSurface
ListPlot3D, ListDensityPlot, and ListContourPlot
MeshRange
Plot3Matrix
PolygonIntersections
Raster
Rectangle
Shading
SphericalRegion
ViewCenter, ViewPoint, ViewVertical

AmbientLight

Ambient light is an option for SurfaceGraphics and Graphics3D.  The default setting of this option is (AmbientLight -> GrayLevel[0] ) which produces no ambient light.  The setting of AmbientLight must be a Hue, GrayLevel or RGBColor directive. The setting specifies that a certain color of lighting should be illuminating the graphics from every direction. Consider the next example where the cube has a green light source from above, and a blue light source from the right, and red ambient light.  Here the ambient light simulates red lighting all over the cube. The green light source combines with the red ambient light to make the top of the cube yellow.  Also the blue light source combines with the red ambient light to make the right side purple.

sources = {{{0, 1, 0}, RGBColor[0, 0.9, 0]}, {{1, 0, 0}, 
            RGBColor[0, 0, 0.75]}};

    
Show[
        Graphics3D[{Cuboid[{1, 1, 1}]}, Boxed -> False, 
          ViewPoint -> {2.4, 0.6, 
              0.6}, 
LightSources -> sources, 
          AmbientLight -> RGBColor[1, 0, 0]]];

AspectRatio

AspectRatio is an option for Show, Plot and other graphic functions.  This discussion is paraphrased from examples provided by Dave Park.  If AspectRatio is set to a number it specifies the height to width ratio of the resulting graphic.  If the AspectRatio is set to Automatic Mathematica sets the width and height so that objects will not be distorted.  Hence the next cell draws a circle so it looks like a circle.

circ=Graphics[{Circle[{2, 2}, 3]},
AspectRatio -> Automatic,PlotRange -> {{-10, 10}, {-10, 10}},Background -> RGBColor[0.982, 0.96, 0.93],{Axes -> True}
];
Show[circ];

In the next cell the AspectRatio is 1/2.  The graphic is not only half as high as it is wide, but the scales along the axes are now also different, and the numbers are packed more closely together in the vertical direction.  Also the circle no longer looks like a circle because of this change of scale.

Show[circ,AspectRatio -> (1/2)];

In the next cell the graphic is twice as high as it is wide, and the scale is more compressed in the horizontal direction. In fact, some of the numbers overlap, but you can click on the graphic and drag it to a larger size to make it look better.  In this case the circle has been stretched vertically.  Of course the setting need not be written as a rational number.  You could just as well use AspectRatio->2.

Show[circ,AspectRatio -> (2/1)];

The first cell below next cell makes a graphic where the height and width are equal.  This looks very much like the first plot.  However the circle might not look like a circle if a different PlotRange was used as in the second cell below.  The second cell below makes a square graphic, but the circle is stretched because of the PlotRange specified.

Show[circ,AspectRatio -> 1];

Show[circ,AspectRatio -> 1,PlotRange->{{-10, 10},{-5, 5}}];

Setting AspectRatio to Automatic will always make the scales along the two axes the same and adjusts the length to width ratio as required.  Using Automatic for AspectRatio assures that figures like circles and squares will not be distorted.  On the other hand, setting AspectRatio to a number causes the height to width ratio of the graphic the have the specified value.

Show[circ,AspectRatio -> Automatic,PlotRange->{{-10, 10},{-5, 5}}];

If you are making geometrical diagrams you will probably want to set AspectRatio to Automatic. If you are plotting an equation you will more often want to set AspectRatio to a number. If the range of y was 1000 times the range of x then it just wouldn't work to use Automatic. If the plot was one inch wide, it would be 1000 inches high!

In Mathematica the default setting of AspectRatio is usually 1/GoldenRatio. The Golden Ratio was a number determined by the ancient Greeks to give the most pleasing proportion for a rectangle.  It is an interesting mathematical number in itself.  Here is a plot using the Golden Ratio.

Plot[(x^3),{x, -5, 5},AspectRatio -> 1/GoldenRatio,PlotRange -> All,Background -> RGBColor[0.982, 0.96, 0.93]
];

It just wouldn't do to use AspectRatio->Automatic for this plot. Try it and see what happens!

Plot[(x^3),{x, -5, 5},AspectRatio -> Automatic,PlotRange -> All,Background -> RGBColor[0.982, 0.96, 0.93]
];

One should keep in mind that the ImplicitPlot (from the standard packages) uses  (AspectRatio->Automatic)  by default. The default setting is often preferred since ImplicitPlot is often used to make Plots of circles and related functions.  However, in some situations this default setting will produce a useless graphic.

BoxRatios

Plot3D, SurfaceGraphics and any functions that return SurfaceGraphics have the BoxRatios option with the default setting {1,1,0.4}. When this default setting is used the length of the two horizontal axes is always equal, and the height of the vertical axis is 40% of either horizontal axis. Using this default setting in the next line one gets the impression that the function rapidly oscillates.

Plot3D[Sin[x y]/3, {x, -3, 3}, {y, 0, 6}, 
        PlotPoints -> 30];

Instead one can set BoxRatios to Automatic to ensure that the resulting graphic is not distorted in that each axis is displayed using the same scale.  When the previous line is evaluated with BoxRatios set to Automatic, the figure is relatively short in the vertical direction since the values of Sin[x y]/3 varies over [-1/3, 1/3] which is much less than the variation of  x, y values . You might find that the line below gives a more accurate impression of how rapidly the function oscillates.

Plot3D[Sin[x y]/3,{x, -3, 3},{y, 0, 6},
PlotPoints -> 30,BoxRatios -> Automatic];

Obviously setting BoxRatios to Automatic would be a very bad choice to plot (Sin[x y]/100) over the same plot range as in the last example.

Contrary to the way Plot3D works ParametricPlot3D sets BoxRatios to Automatic by default.  This default setting is used in the next example and produces a nice parametric plot of a 3D-spiral.

\(\(ParametricPlot3D[{Cos[2\ t], Sin[2\ t], 10/t}, 
	{t, 2, 12}, 
        Axes -> False, ImageSize -> {200, 300}];\)\)

Now in the next line the default setting for BoxRatios produces a graph that's very tall and thin

\(\(ParametricPlot3D[{Cos[2\ t], Sin[2\ t], 30/t}, 
	{t, 0.05, 2}, 
        Axes -> False, ImageSize -> {200, 300}];\)\)

A better presentation of the last graphic is made by setting BoxRatios to {1,1,0.4} in the next line.

ParametricPlot3D[{Cos[2 t], Sin[2 t], 30/t},
	{t, 0.05, 2},Axes -> False,ImageSize -> {200, 300},BoxRatios -> {1, 1, 1.5}];

Graphics3D also set BoxRatios to Automatic by default.  In addition the following functions in the standard packages set BoxRatios to Automatic by default; 
   ListPlotVectorField3D
   PlotVectorField3D
   PlotGradientField3D
   SphericalPlot3D
   CylindricalPlot3D
   PointParametricPlot3D
   ListSurfacePlot3D
   ScatterPlot3D
   ContourPlot3D
   ListContourPlot3D
 
I know of no other functions with the default setting  (BoxRatios->Automatic).

Circle, Disk

The basic use of Circle is demonstrated with the next cell.

crv = Plot[x^3, {x, 0, 3}, DisplayFunction -> Identity];
cir1 = 
        Graphics[{Circle[{1.25, 12.5}, {0.25, 2.5}]   }];
\(\(Show[crv, cir1, DisplayFunction -> $DisplayFunction, 

        PlotRange -> {\(-2\), 30}];\)\)

The next cell demonstrates a circle with radi specified using scaled coordinates.  In this case the radius is 1/4 the width of the graphic in the horizontal direction and 1/4 of the height of the graphic in the vertical direction.  Hence the diameter is 1/2 the size of the graphic in each direction.

cir2 = 
        Graphics[{Circle[{1.25, 12.5}, 
              Scaled[{0.25, 0.25}]]   }];
\(\(Show[crv, cir2, DisplayFunction -> $DisplayFunction, 

        PlotRange -> {\(-2\), 30}];\)\)

The next cell makes a circle with radi given as a combination of scaled coordinates and absolute coordinates.

cir3 = 
        Graphics[{Circle[{1.5, 10}, 
              Scaled[{0.1, 0.125}, {0.7, 6}]]   }];
\(\(Show[crv, cir3, DisplayFunction -> $DisplayFunction, 

        PlotRange -> {\(-2\), 30}];\)\)

The documentation for Circle indicates Offset[{ax,ay}] can be used to specify radii in printer points.  This is demonstrated below where the circle is round with a radius of 15 printer points regardless of the AspectRatio or ImageSize.  You can even resize the graphic, and the size of the circle will not change!
 
Offset [{(Subscript[a, x]), (Subscript[a, y])}] can also be used to specify radius of a Disk with similar results.

crv = Plot[x^3, {x, 0, 3}, DisplayFunction -> Identity];
\(\(\(cir = Graphics[{Circle[{1.5, 10}, Offset[{15, 15}]]\ \ }];\)\(
\)
    \)\ \)
\(\(Show[crv, cir, DisplayFunction -> $DisplayFunction, 

        AspectRatio -> 1, ImageSize -> {180, 180}];\)\)

ColorFunction

Most graphics functions in Mathematica have a ColorFunction option.  The value of a function is used to specify the color or shade of gray used to make each portion of the graphic.  Some examples of ColorFunction are shown below. The "#&" notation is explained in my discussion of Slot, SlotSequence.

\(\(Plot3D[
        Sin[x + y], {x, \(-π\), π}, {y, \(-π\), π}, 
	
        ColorFunction -> \((If[# < 1/2, GrayLevel[0.5], 
                GrayLevel[0.8]] &)\)];\)\)

\(\(Plot3D[
        Sin[x + y], {x, \(-π\), π}, {y, \(-π\), π}, 
	
        ColorFunction -> \((RGBColor[0.1 + 0.8  #, 0, 0.9 - 0.8  #] &)\), 

        Mesh -> False, PlotPoints -> 30];\)\)

You will find we can't have a ColorFunction that is sometimes a color and sometimes a GrayLevel.  However, we can still get the same result by using RGBColor[a,a,a]  in place of GrayLevel[a] as in the next cell.

\(\(Plot3D[
        Sin[x + y], {x, \(-π\), π}, {y, \(-π\), π}, 
	
        ColorFunction -> \((If[# < 1/2, Hue[0.4], 
                RGBColor[0.8, 0.8, 0.8]] &)\)];\)\)

ColorFunctionScaling

ColorFunctionScaling is an option for SurfaceGraphics, DensityGraphics, ContourGraphics, Raster and functions that return these graphic objects.  The default setting is (ColorFunctionScaling->True) in which case function values are scaled such that the minimum value is mapped to 0 and the maximum value is mapped to 1.  These mapped values are then used to determine a color for each point on the plot.  The color is determined from the setting of the ColorFunction option. When the setting (ColorFunctionScaling->False) is used the function values are sent directly to the function determined by the ColorFunction setting. Notice when the setting (ColorFunction->Automatic) is used a negative value has the same effect as 0 and a value greater than 1 has the same effect as 1. 
The cells that follow demonstrate how ColorFunctionScaling affects DensityGraphics and ContourGraphics.

DensityPlot[Cos[x y]/10 + 1/2, {x, -3, 3}, {y, -3, 3}, 
        ColorFunctionScaling -> True];
DensityPlot[Cos[x y]/10 + 1/2, {x, -3, 3}, {y, -3, 3}, 
        ColorFunctionScaling -> False];

ContourPlot[Cos[x y]/10 + 1/2, {x, -3, 3}, {y, -3, 3}, 
        ColorFunctionScaling -> True];
ContourPlot[Cos[x y]/10 + 1/2, {x, -3, 3}, {y, -3, 3}, 
        ColorFunctionScaling -> False];

ColorFunctionScaling is a SurfaceGraphics option and only affects rendering of SurfaceGraphics when the setting (Lighting->False) is used. Plot3D returns SurfaceGraphics and the next cell demonstrates the use of ColorFunctionScaling with Plot3D.

\(\(\(Plot3D[
        Cos[x\ y]/10 + 1/2, {x, \(-3\), 3}, {y, \(-3\), 
          3}, 
ColorFunctionScaling -> True, 
        Lighting -> False];\)\(
\)
    \)\)
Plot3D[
        Cos[x y]/10 + 1/2, {x, -3, 3}, {y, -3, 
          3}, 
ColorFunctionScaling -> False, 
        Lighting -> False];

ColorOutput

?ColorOutput

According to technical support at  Wolfram Research ColorOutput is primarily intended for those situations when you are exportiing Mathematica graphics to Adobe post script or EPS.  They say it allows some additional control over how the color output is handled in these circumstances, but I haven't come up with an example.

DisplayFunction

DisplayFunction is an option for most graphics functions, and is normally used to indicate whether the graphics should be displayed.  As long as you haven't changed the value assigned to $DisplayFunction you can ensure graphics are displayed by giving DisplayFunction the setting $DisplayFunction.  To prevent the display of graphics DisplayFunction should be set to Identity.

For example the next cell shows a plot sin[x], x-(x^3)/6 on the same graphic, but before making the combined plot it makes and displays the individual plots.

plt1 = Plot[Sin[x], {x, -π, π}];
plt2 = Plot[x - ((x^3)/6), {x, -2, 2}];
Show[plt1, plt2];

You can supress display of the individual plots by using the DisplaFunction options in the next cell.  Here DisplayFunction -> Identity prevents display of the individual graphs.  To ensure the combined plots are displayed we must use DisplayFunction -> $DisplayFunction inside Show.

plt1 = 
        Plot[Sin[x], {x, -π, π}, 
          DisplayFunction -> Identity];
plt2 = 
        Plot[x - ((x^3)/6), {x, -2, 2}, 
          DisplayFunction -> Identity];
Show[plt1, plt2, 
        DisplayFunction -> $DisplayFunction];

A labor saving way to change the setting of DisplayFunction is given in my discussion of Block.

DisplayString

The next line shows the DisplayString usage message.

?DisplayString

The Postscript expression returned by DisplayString can sometimes be used by other programs.  We can also use the Postsript to make Graphics output that we can't otherwise make without manual adjustment as I demonstrate below.  First the next Input makes (ps) the PostScript used to render a plot.

gr = 
        Plot[Sin[x], {x, 0, π}, DisplayFunction -> Identity, 
          PlotPoints -> 5, PlotDivision -> 2];
ps = DisplayString[gr]

Then the next Input renders the graphics with a non-default setting for CellMargins.

\(\(\(\ \)\(NotebookWrite[\ 
      SelectedNotebook[], \ 
\ \ \ \ \ \ \ \ \ Cell[
        GraphicsData["PostScript", \ ps], \ "Graphics", \ 
        CellMargins -> {{150, 0}, {0, 
              30}}]\ 
]\)\)\)

EdgeForm

The next cell displays the usage message for EdgeForm.

?EdgeForm

The usage message for EdgeForm indicates  EdgeForm is a "three-dimensional graphics directive" this indicates it can be used inside Graphics3D and with functions that produce Graphics3D expressions.  ParametricPlot3D produces Graphics3D, and it's usage message indicates that ParametricPlot3D[{fx,fy,fz,s},{x,xmin,xmax},{ymin,ymax}] produces a plot shaded according to the color specification (s).  Here (s) can be a single three-dimensional graphics directive or a list of three-dimensional graphics directives.

Consider the next cell where the default EdgeForm around polygons is used.

ParametricPlot3D[{x, y, Sin[x y/3]}, {x, 0, 3}, {y, 0, 
          3}];

The next cell makes the same graphic except no edges are drawn around the polygons.

ParametricPlot3D[{x, y, Sin[x y/3], EdgeForm[]}, {x, 0, 3}, {y, 0, 
          3}];

The next cell plots the same function using a gray edges around the polygons.

ParametricPlot3D[{x, y, Sin[x y/3], EdgeForm[GrayLevel[0.5]]}, {x, 
          0, 3}, {y, 0, 3}];

The next cell uses colored edges where the color varies as a function of x and y.

ParametricPlot3D[{x, y, Sin[x y/3], 
          EdgeForm[RGBColor[1 - x/3, 1 - y/3, 0]]}, 
{x, 0, 
          3}, {y, 0, 3}];

The next cell uses thick colored edges where the color varies as a function of x and y.

ParametricPlot3D[{x, y, 
          Sin[x y/3], 
EdgeForm[{RGBColor[1 - x/3, 
                1 - y/3, 0], 
              AbsoluteThickness[4]}] }, 
 {x, 0, 3}, {y, 
          0, 3}, PlotPoints -> 8
];

An example is given below where EdgeForm is used with Grapgics3D.  Here EdgeForm[] indicates no edges should be drawn around the polygons.

Needs["Graphics`Shapes`"]
Show[Graphics3D[{EdgeForm[], Torus[]}]];

In the next cell Gray edges around the polygons are used.

Show[
        Graphics3D[{EdgeForm[Thickness[0.01], GrayLevel[0.5]], 
            Torus[]}]];

Keep in mind that DensityPlot, ListDensityPlot, ListPlot3D, Plot and Plot3D don't produce Graphics3D expressions.  Instead one should use the options Mesh and MeshStyle to get similar results with DensityPlot, ListDensityPlot, ListPlot3D, Plot and Plot3D.

Epilog, Prolog

Epilog and Prolog are options for Graphics functions which give are used to give a list of graphics primative (Circle, Line, Point, ...) to be rendered before or after the main part of the graph.  The Prolog  graphics are rendered before the main part of the graphics.  The Epilog graphics are rendered after the main part of the graphics.

The cell below shows red points drawn before the line using Prolog.  Also shown are red points drawn after the lines using Epilog.

\(\(data1 = Table[{x, x}, {x, 0, 6}];\)
\)
\(Block[{$DisplayFunction = Identity}, 
	

      PointsFirst = 
        ListPlot[data1, 
          PlotJoined -> 
            True, 
		PlotStyle -> {GrayLevel[0], 
              Thickness[0.02]}, 
		Prolog -> {Hue[1], PointSize[0.1], 
              Point /@ data1}, 
\ \ \ \ \ \ PlotRange -> {{\(-0.5\), 
                6}, {\(-0.5\), 6}}]; 
	

      PointsLast = 
        ListPlot[data1, 
          PlotJoined -> 
            True, 
		PlotStyle -> {GrayLevel[0], 
              Thickness[0.02]}, 
		Epilog -> {Hue[1], PointSize[0.1], 
              Point /@ data1}, 
\ \ \ \ \ \ PlotRange -> {{\(-0.5\), 
                6}, {\(-0.5\), 6}}];
]
\)
Show[GraphicsArray[{PointsFirst, PointsLast}], 
        ImageSize -> {400, 100}];

The next example was inspired by a problem Jurgen Tisher answered in the MathGroup.  You should be wary of using  Epilog and Prolog for applications where you may combine the results with other graphics at a later time using Show.  The reason for this is demonstrated in this example.

data1 = Table[{x, x}, {x, 0, 6}];
\(\(data2 = Table[{x, x + 2}, {x, 0, 6}];\)
\)
\(Block[{$DisplayFunction = Identity}, 
	

      p1 = ListPlot[data1, 
          PlotJoined -> 
            True, 
		Epilog -> {Hue[1], 
					PointSize[0.06], 
              Point /@ data1}, 
\ \ \ \ \ \ PlotRange -> {{\(-0.5\), 
                6.5}, {\(-0.5\), 8.5}}]; 
	

      p2 = ListPlot[data2, 
          PlotJoined -> 
            True, 
		Epilog -> {Hue[1], 
					PointSize[0.06], 
              Point /@ data2}, 
\ \ \ \ \ \ PlotRange -> {{\(-0.5\), 
                6.5}, {\(-0.5\), 8.5}}];
]
\)
Show[GraphicsArray[{p1, p2}], ImageSize -> {400, 100}];

In the GraphicsArray above the Points made with Epilog are shown in the plots for p1 and p2.  When the two graphics below are combined only the Epilog graphics for p1 are shown.

Show[p1, p2];

The Epilog graphics for p2 were not displayed because Show concatenates together the options for each graphic.  As a result only the first Epilog options and the first Prolog option is used.  By using FullGraphics the graphics for p1 and p2 can be converted to graphic primitives, and all the intended graphics are displayed.  However, this demonstration is misleading because the manual settings used for PlotRange above were carefully selected to ensure the result below comes out looking good.  If you make p1 and p2 using the PlotRange->Automatic the graphic below doesn't come out as nice.  

It turns out that Prolog has the same weakness.

Show[FullGraphics[p1], FullGraphics[p2]];

FrameTicks

A user wanted to present data on the y axis and refer to it with 2 equivalent scales 
(degrees Fahrenheit and degrees Celcius)

Wolf Hartmut gave a solution where he demonstrates by first defining a fever curve (temp) in Centigrade units, and a Plot of the curve is assigned to graphC.

\(\(\(tempC = 
        Join[Table[Random[Real] + 37.25, {4}], 
          Table[6  x/E^x + Random[Real] + 37.25, {x, 0, 6, 0.2}]];\)\(
\)
    \)\)
graphC = 
        ListPlot[tempC, PlotJoined -> True, PlotRange -> All, 
          Frame -> True, Axes -> None, 
          FrameTicks -> {Automatic, Automatic, None, None}, 
          DisplayFunction -> Identity];

Ticks2 are the original FrameTicks redefined so the text for Clesius degrees are placed at the equivalent place on a graph with Farenheight units.

Needs["Miscellaneous`Units`"];
Ticks2 = {ConvertTemperature[#1, Centigrade, Fahrenheit], 
              If[#2 == "", #2, #1], #3, #4} & @@@ FullOptions[
              graphC, FrameTicks][[2]];

Next the fever curve is converted to Fahrenheit, and  this is plotted with Ticks2.  The altered FrameTicks are used on the left edge of the graph.

tempF = ConvertTemperature[#, Centigrade, Fahrenheit] & /@ 
          tempC;

    
ListPlot[tempF, PlotJoined -> True, PlotRange -> All, 
        Frame -> True, Axes -> None, 
        FrameTicks -> {Automatic, Automatic, None, Ticks2}, 
        FrameLabel -> {None, "Fahrenheit", 
            None, "Centigrade"}];

A user wanted to have two graphs displayed one above the other in a GraphicsArray, and 
have the vertical axes alligned with eachother

Bob Hanlon recommended using an identical but  "invisible" FrameTick on each graph's axis that is slightly wider than the widest actual tick label as below.

\(\(\(fig1 = 
        Plot[x, {x, 0, 10}, 
          Frame -> 
            True, 
FrameTicks -> {Automatic, 
Join[
Table[{k, k}, {k, 0, 10, 2}], 
                Table[{k, "    "}, {k, 0, 10, 1}]
], 
              Automatic, Automatic
}, 
          DisplayFunction -> 
            Identity
];\)\(
\)
    \)\)
\(\(\(fig2 = 
        Plot[x^4, {x, 0, 10}, Frame -> True, 
          FrameTicks -> {Automatic, 
Join[
Table[{k, k}, {k, 0, 2000, 500}], 
                Table[{k, "    "}, {k, 0, 2100, 
                    100}]
], Automatic, 
              Automatic
}, 
          DisplayFunction -> 
            Identity
];\)\(
\)
    \)\)
Show[GraphicsArray[{{fig1}, {fig2}}], 
        ImageSize -> {300, 388}];

HiddenSurface

HiddenSurface is an option for SurfaceGraphics, Plot3D and other funtions that return SurfaceGraphics.  The default setting is (HiddenSurface->True) which causes the surface to be drawn using simulated lighting as long as the setting (Lighting->True) is used.  The setting (HiddenSurface->False) draws the surface as a transparent wire mesh.  Evaluating the next cell demonstrates both HiddenSurface settings. The Shading option is used to render the surface as a mesh of opaque mesh of polygons.

Plot3D[Exp[-((x^4) + (y^4))], {x, -2, 2}, {y, -2, 2}, 
      HiddenSurface -> True]; 
    Plot3D[Exp[-((x^4) + (y^4))], {x, -2, 2}, {y, -2, 2}, 
      HiddenSurface -> False];

ImplicitPlot

Either form of ImplicitPlot will take the options FormatType, ImageSize, TextStyle even though they aren't returned by Options[ImplicitPlot].  ImplicitPlot also takes the options ColorFunction, Compiled, ContourLines, ContourShading and ContourStyle but only when the ContourPlot method is used.  Each of these options except Compiled is demonstrated below.

Needs["Graphics`ImplicitPlot`"];
\(\(ImplicitPlot[x^2 + y^2 == 1/2, {x, 0, 0.75}, {y, 0, 0.75}, \ 

        ColorFunction -> \((If[# < 0.5, \ GrayLevel[0.7], \ 
                GrayLevel[1]] &)\), \ ImageSize -> {200, 200}, \ 
        ContourLines -> False, 
ContourShading -> True];\)\)

Needs["Graphics`ImplicitPlot`"];
\(\(ImplicitPlot[
        ArcSin[x] - y == 0, {x, \(-1\), 1}, {y, \(-π\)/2, π/2}, 

        PlotLabel -> HoldForm[ArcSin[x] = y], 
        ContourStyle -> Dashing[{0.02, 0.02}], \ 
	
        TextStyle -> {FontColor -> Hue[0.7]}, 
        FormatType -> TraditionalForm];\)\)

The documentation indicates ImplicitPlot uses one of two methods.  In the two cells above the ContourPlot method was used since a range of values for x and y were specified.  When the ContourPlot method is used the ContourStyle option is used to make the curve dotted.  In the next line the Solve method is used since no range is given for the range of (y) values.  Since the Solve method is used the PlotStyle option has to be used to make the curve dotted.  Whether you use PlotStyle or ContourStyle depends on the ImplicitPlot method being used (ContourPlot method, or Solve method).

Needs["Graphics`ImplicitPlot`"];
\(\(ImplicitPlot[ArcSin[x] - y == 0, {x, \(-1\), 1}, 
\ 
        PlotStyle -> Dashing[{0.02, 0.02}]\ ];\)\)

Also note the documentation indicates ImplicitPlot uses the same options as plot when the solve method is used.  Actually MaxBend and PlotDivision are plot options, but they aren't recognized by either method of ImplicitPlot.

One should keep in mind that ImplicitPlot uses (AspectRatio->Automatic) by default.  This ensures that the plot of a circle (below) looks like a circle.

Needs["Graphics`ImplicitPlot`"];
ImplicitPlot[x^2 + y^2 == 9, {x, -3, 3}];

However the default option (AspectRatio->Automatic) causes a problem in the next cell.  In this case the range of values on the vertical axis is much larger than the range of values on the horizontal axis.  In this case the default setting for AspectRatio produces a useless graphic.

Needs["Graphics`ImplicitPlot`"];
ImplicitPlot[y + x == Tan[x], {x, 0.8, 1.56}];

Instead the AspectRatio used by most other plot commands (AspectRatio->1/GoldenRatio) produces a much more useful graphic in the next line.

Needs["Graphics`ImplicitPlot`"];
ImplicitPlot[y + x == Tan[x], {x, 0.8, 1.56}, 
        AspectRatio -> 1/GoldenRatio];

In the following line Implicit Plot uses the default options and the curves aren't smooth.  To make the graphs smooth a value for the PlotPoints option has to be specified.  The default setting is PlotPoints->25.  The setting used in the second attempt work better.

ImplicitPlot[
        Sin[2 x]  +  Cos[3 y]  ==  1, {x, -8, 8}, {y, -8, 
          8}];

\(\(ImplicitPlot[
        Sin[2\ x]\  + \ Cos[3\ y]\  == \ 1, {x, \(-8\), 8}, {y, \(-8\), 8}, 

        PlotPoints -> 200];\)\)

LightSources

The lighting model in Mathematica allows you to simulate lighting from one or more light sources when the setting (Lighting->True) is used. Each light source has a certain positioon and color. Cartesian coordinates relative to the display are used to specify the position of light sources.  The axes are oriented with the positive x - axis right of the display, the positive y - axis above the display, and the positive z - axis in front of the display.  Some examples are given below to demonstrate.

First we have an example where 
{{0,1,0},RGBColor[1,0,0]} is a red light source from above, and 
{{1,0,0},RGBColor[0,1,0]} is a green light source from the right.

Show[
        Graphics3D[{Cuboid[{1, 1, 1}]}, Boxed -> False, 
          ViewPoint -> {2.4, 0.6, 
              0.6}, 
LightSources -> {{{0, 1, 0}, 
                RGBColor[1, 0, 0]}, {{1, 0, 0}, 
                RGBColor[0, 1, 0]}}
]];

In the next cell we have an example where 
{{0,-1,0},RGBColor[1,0,0]}is a red light source from below,and
{{-1,0,0},RGBColor[0,1,0]}is a green light source from the left.

Show[
        Graphics3D[{Cuboid[{1, 1, 1}]}, Boxed -> False, 
          ViewPoint -> {2.4, -0.6, -0.6}, 
LightSources -> {{{0, -1, 0}, 
                RGBColor[1, 0, 0]}, {{-1, 0, 0}, 
                RGBColor[0, 1, 0]}}
]];

In the next cell we have an example where
{{0,0,1},RGBColor[1,0,0]}is a red light source from directly infront of the display and
{{1,0,0},RGBColor[0,1,0]}is a green light source from the right.

Show[
        Graphics3D[{Cuboid[{1, 1, 1}]}, Boxed -> False, 
          ViewPoint -> {2.4, 0.6, 
              0.6}, 
LightSources -> {{{0, 0, 1}, 
                RGBColor[1, 0, 0]}, {{1, 0, 0}, 
                RGBColor[0, 1, 0]}}
]];

In the examples above the cubes were oriented so that two surfaces were nearly normal to the incident light rays. Hence reflected light was nearly identical to the incident light. In the next example the default ViewPoint is used, and each of three sides are iluminated by more than one light source.

Show[
        Graphics3D[{Cuboid[{1, 1, 1}]}, 
          Boxed -> 
            False, 
LightSources -> {
{{0.1, -0.2, 0.5}, 
                RGBColor[1, 0, 0]}, 
{{0.7,   0.0,  
                  0.7}, RGBColor[0, 1, 
                  0]}, 
{{0.0,    1.0, 0.2}, 
                RGBColor[0, 0, 1]}}
]];

The Mathematica lighting model doesn't account for shadows. This is normally preffered for scientific illustrations, but not for life like 3D graphics. The fact that Mathematica doesn't account for shadows is demonstrated with the code in the next cell in which the top of all cubes are red, and the right side of all cubes are green.

Show[
        Graphics3D[{Cuboid[{0, -1.3, 0}, {1, -0.3, 
                1}], 
Cuboid[{0, 0, 0}, {1, 1, 
                1}], 
Cuboid[{0, 0, -0.3}, {1, 
                1, -1.3}]
}, 
          ViewPoint -> {2.4, 0.6, 
              0.6}, 
LightSources -> {{{0, 1, 0}, 
                RGBColor[1, 0, 0]}, {{1, 0, 0}, 
                RGBColor[0, 1, 0]}}
]];

For the next example we need to load a graphics package.

<< Graphics`Shapes`

Keep in mind the coordinate system used for LightSources has nothing to do with the axes of the Graphics3D object. For evidence of this consider the next cell which make an annimation of a rotating sphere with only one light source from the right and a little ambient light.  If you click on one of the graphic cells you can see the box spining around, but the sphere always looks the same.

gr1 = Sphere[1, 50, 25];

Table[
Show[
          Graphics3D[{EdgeForm[], 
              gr1}], 
LightSources -> {{{1, 0, 0}, 
                RGBColor[1, 0, 0]}}, 
AmbientLight -> 
            GrayLevel[0.25], 
SphericalRegion -> 
            True, 
ViewPoint -> {1.7 Cos[θ], 
              1.7 Sin[θ], 2. }], 
{θ, 0, 
          2  π, π/10}];

The next cell makes an annimation showing a torus lit with a moving light source. The only thing that changes in the annimation is the direction of the light source.  The virtural location of the light moves in a counter clockwise circle around the viewing surface.

gr1 = Torus[3, 1, 30, 30];
Table[
        Show[Graphics3D[{EdgeForm[], 
              gr1}], 
LightSources -> {{{Cos[a], 
                  Sin[a], 1}, GrayLevel[1]}}], {a, 0, 
          2  π, π/8}];

ListPlot3D, ListDensityPlot, ListContourPlot

ListPlot3D, ListDensityPlot, and ListContourPlot are used to plot a matrix of numeric values.  By default these functions simply label the resulting tick marks as if the rows and columns of the matrix are numbered 1, 2, 3, ...  In many cases you will want to number the TickMarks on the x and y axes so they coorespond to a certain range of values.  These functions have an option called MeshRange that does this.

Mesh, MeshStyle

By default Plot3D, ListPlot3D, DensityPlot and ListDensityPlot3D make a black mesh over the graphic.  In the next cell the setting (Mesh->False) is used to supporess this grid.

Plot3D[Sin[x + y], {x, -π, π}, {y, 0, π}, 
        Mesh -> False];
DensityPlot[Sin[x + y], {x, -π, π}, {y, 0, π}, 
        Mesh -> False];

In the next cell the MeshStyle option is used to make a green mesh.  Using this option one can specify the color and/or thickness of the grid.  You could also make a mesh of dashed lines if you wanted to.

Plot3D[Sin[x + y], {x, -π, π}, {y, 0, π}, 
        MeshStyle -> {Hue[0.3, 1, 0.7]}];
DensityPlot[Sin[x + y], {x, -π, π}, {y, 0, π}, 
        MeshStyle -> {Hue[0.3, 1, 0.7]}];

ParametricPlot3D requires use of EdgeForm to do the same thing as Mesh and MeshStyle.  EdgeForm is also used with Graphics3D primitives rather than Mesh, MeshStyle.

MeshRange

MeshRange is an option for ListPlot3D, ListDensityPlot, ListContourPlot, SurfaceGraphics, DensityGraphics, and ContourGraphics. ListPlot3D, ListDensityPlot, and ListContourPlot are used to plot a matrix of numeric values.  When the default setting (MeshRange->Automatic) is used these functions simply label the resulting tick marks as if the rows and columns of the matrix are numbered 1, 2, 3, ... This is what you get from evaluating the next cell.  These functions can't do any better because there is nothing in the data indicating otherwise.

data = 
        Table[(((x - 35))^2) (((y - 70))^2)/100, {x, 30, 40, 0.5}, {y, 60, 
            80, 1}];
ListPlot3D[data, MeshRange -> Automatic];
ListDensityPlot[data, MeshRange -> Automatic];
ListContourPlot[data, MeshRange -> Automatic];

However, in the case above we know that the rows of data correspond to x values between 30 and 40. Likewise the columns of data correspond to y values between 60 and 80.  In the next cell the MeshRange option is used to ensure the TickMarks are relavent for this data.

ListPlot3D[data, MeshRange -> {{30, 40}, {60, 80}}];
ListDensityPlot[data, 
        MeshRange -> {{30, 40}, {60, 80}}];
ListContourPlot[data, 
        MeshRange -> {{30, 40}, {60, 80}}];

Offset, Scaled

?Offset

In the next cell pnt1 is a red point at {1,0.025}.  The graphic made also shows pnt2, a blue point 20 printer points to the right and 10 printer points above {1,0.025}.  Notice distances in printer points aren't related to the scale on the axes.

pnt1=Graphics[{PointSize[0.03],RGBColor[0.9, 0, 0],
Point[{1, 0.025}]
}];

pnt2=Graphics[{PointSize[0.03],RGBColor[0, 0, 0.9],
Point[Offset[{20, 10}, {1, 0.025}]]
}];

Show[{pnt1, pnt2}, 
        PlotRange -> {{-5, 5}, {-0.1, 0.1}}, 
        Axes -> True];

The remaining examples used Offset and Scaled.

?Scaled

In the next cell pnt1 is a red point positioned such that the distance from the left edge of the graphic is 10% of the graphic width, and and the distance from the bottom of the graphic is 5% of the graphic height. Also shown is pnt2, a blue point 20 printer points to the right and 10 printer points above pnt1.

pnt1=Graphics[{PointSize[0.03],RGBColor[0.9, 0, 0],
Point[Scaled[{0.1, 0.05}]]
}];
pnt2=Graphics[{PointSize[0.03],RGBColor[0, 0, 0.9],
Point[Offset[{20, 10}, Scaled[{0.1, 0.05}]]]
}];
Show[{pnt1, pnt2}, 
        PlotRange -> {{-5, 5}, {-0.1, 0.1}}, 
        Axes -> True];

In the next cell pnt1 is a red point at {1,0.025}.  Also shown is pnt2, a blue point at the position Scaled[{0.1, 0.05}, {1, 0.025}] which is to the right of pnt1 by 10% of the graphic width, and above pnt1 by 5% of the graphic height.  In addition pnt3 is shown which is a green point 10 printer points to the right of pnt2, and 20 printer points higher than pnt2.

pnt1=Graphics[{PointSize[0.03],RGBColor[0.9, 0, 0],
Point[{1, 0.025}]
}];
pnt2=Graphics[{PointSize[0.03],RGBColor[0, 0, 0.9],
Point[Scaled[{0.1, 0.05}, {1, 0.025}]]
}];
pnt3=Graphics[{PointSize[0.03],RGBColor[0, 0.9, 0],
Point[Offset[{10, 20}, 
                    Scaled[{0.1, 0.05}, {1, 0.025}]]]
}];
Show[{pnt1, pnt2, pnt3}, 
        PlotRange -> {{-5, 5}, {-0.1, 0.1}}, 
        Axes -> True];

A practical use of Offset is given in the next cell where it's used to specify the position of some text.

plt = 
          Plot[BesselJ[2, x], {x, 0, 8}, DisplayFunction -> Identity, 
            PlotRange -> {-0.4, 0.6}];

pnt = 
          Graphics[
{PointSize[0.02], 
              Point[{3.05424, BesselJ[2, 3.05424]}]}];

txt=Graphics[{
Text["Local Maxima",Offset[{12, 0}, {3.05424, BesselJ[2, 3.05424]}],{-1, -1}]
}];
Show[{plt, pnt, txt}, 
        DisplayFunction -> $DisplayFunction];

Plot3Matrix

Plot3Matrix is an option for Graphics3D, SurfaceGraphics and funtions that return Graphics3D or SurfaceGraphics.  This option is obsolete and I suspect it is only supported for backward compatibility.  The functinality of Plot3Matrix is provided by the options ViewCenter, ViewPoint, and ViewVertical.

PolygonIntersections

PolygonIntersections is an option for Graphics3D and funtions that return Graphics3D objects.

Options[Graphics3D, PolygonIntersections]

When the setting  PolygonIntersections->False  is used the graphics are rendered as a collection of non-intersecting triangles.  In the next cell I make a Graphics3D object with non-default setting (PolygonIntersections->False).

gr = 
        Graphics3D[{
Polygon[{{0, 0, 1}, {0, 1, 1}, {1, 1, 
                  1}, {1, 0, 1} }], 
Polygon[{{0.5, 0, 
                  0}, {0.5, 1, 0}, {0.5, 1, 2}, {0.5, 0, 
                  2}}]
}, 
          PolygonIntersections -> False];

I can't inderstand why but my attempt to display the graphics in the next cell doesn't work when using Mathematica 4.1 under Windows 98.

Show[gr, PlotRange -> All];

On my computer the above graphics can be displayed if I nest use of Show, and specify (PlotRange->All).

Show[Show[gr], PlotRange -> All];

The next cell shows us how Mathematica divided the above polygons into non-intersecting triangles.

polygons = Cases[Show[gr], _Polygon, {0, -1}] // Chop

Raster

The next cell makes a matrix of values between 0.08 and 1.

mtrx = Table[(i + j)/25.0, {i, 1, 10}, {j, 1, 15}];

In the next cell Raster makes an array of gray blocks with one block for each element of the matrix.  A value 0 in the matrix corrosponds to a black block in the graphic, and a value of 1 in the matrix corrosponds to a white block in the graphic.  Linear interpolation is used between 0.08 and 1. In this example we have a 10×15 matrix and the portion of the graphic covered with gray blocks goes from 0 to 15 in the horizontal direction, and from 0 to 10 in the vertical direction.

Show[Graphics[{Raster[mtrx]}]];

In the next cell the Raster graphic is displayed over a red rectangle specified as  Rectangle[{-1,-1},{16,11}].  You can see that the gray blocks covers the range described above.

rect = 
        Rectangle[{-1, -1}, {16, 11}];
Show[Graphics[{Hue[0], rect, Raster[mtrx] }]];

In the next cell we give Raster the coordinates {{1,2},{14,9}} as a second argument.  Here the second argument of Raster indicates that the array of gray blocks should go from 1 to 14 in the horizontal direction and from 2 to 9 in the vertical direction. 

I don't demonstrate it here but Scaled and Offset corrdinates can be used in the second argument given to Raster.  See another section for an explanation of Scaled, Offset.

Show[Graphics[{Hue[0],rect,Raster[mtrx,{{1, 2}, {14, 9}}]}] ];

Now consider the next cell where we make a matrix of numbers between  -1.8333 and 2.3333.  Raster treats negative matrix elements as 0 and treats matrix elements greater than 1 as 1.  As a result a lot of the array blocks are black or white.

mtrx = 
        Table[(i + j - 13)/6.0, {i, 1, 11}, {j, 1, 16}];
Show[Graphics[{Raster[mtrx]}]];

In the next cell we use the same matrix with elements between -1.8333 and 2.3333, and we give Raster {-1.9, 2.4} as a third argument.  This says a value of  -1.9  in the matrix should make a black cell, a value of  2.4  in the matrix should make a white cell.  Linear interpolation is used for matrix elements between  -1.9  and  2.4.

Show[Graphics[{Raster[mtrx,{{0, 0}, {10, 15}},{-1.9, 2.4}]}]];

In the next cell we give Raster {-3, 3} as a third argument.  This says a value of -3 in the matrix should make a black cell, a value of 3 in the matrix should make a white cell, and a linear interpolation should be used between -3 and 3.  Since all elements of the matrix are between -1.8333 and 2.3333, all blocks in the array are in the middle range of the gray scale.

Show[Graphics[{Raster[mtrx,{{0, 0}, {10, 15}},{-3, 3}]}]];

In the next cell  (rstr1)  uses black if a matrix element is  -1.9,  and uses white if a matrix element is  2.4.  But then  (rstr2)  uses black if a matrix element is  2.4, and uses white if a matrix element is  -1.9.  As a result the shades in (rstr1) are the complement of the shades in (rstr2).

rstr1=Graphics[{Raster[mtrx,{{0, 0}, {10, 15}},{-1.9, 2.4}]}];
rstr2=Graphics[{Raster[mtrx,{{0, 0}, {10, 15}},{2.4, -1.9}]}];
Show[GraphicsArray[{rstr1, rstr2}]];

Raster has options ColorFunction and ColorFunctionScaling which are explained in another section.

Rectangle

Rectangle is a griphics primative. The Rectangle coordinates can be Scaled, Offset, or (Scaled and Offset) and these features are explained in another section.  Except for non-stnadard coordinates the basic use of Rectangle is well documented.  On the other hand  Rectangle has an interesting feature in that it can take a graphics object as a third argument, and I demonstrate this feature here.

Consider the two plots made with the next cell.

gr1 = 
        Plot[((Sin[x] Sin[5  x])/x), {x, -14, 14}, 
          PlotRange -> All];

gr2 = 
        Plot[((Sin[x] Sin[5  x])/x), {x, 10, 14}, 
          PlotRange -> All];

A nice presentation of these plots would have the graphic with a smaller plot range in the upper right corner used to display the one with a larger plot range.  We can do that by giving Rectangle these graphics as third arguments in the next cell.

Show[
        Graphics[{
Rectangle[{0, 0}, {1.02, 1.02}, gr1], 
            Rectangle[{0.6, 0.7}, {1, 1}, gr2]}], PlotRange -> All, 
        ImageSize -> {500, 400}];

To explain what happens above consider the next cell which is similar to the previous cell.  The next cell makes a red rectangle and a blue in the upper left corner of the red rectangle (Hue[0] is red, and Hue[0.6] is blue). In the previous cell the first Rectangle had (gr1) as a third argument, and that makes the rectangle filled in with graphic (gr1)  instead of a solid color.  Then the second Rectangle in the previous cell had (gr2) as a third argument, and that makes the second rectangle filled in with graphic (gr2) instead of a solid color.

Show[
        Graphics[{
Hue[0], 
            Rectangle[{0, 0}, {1.02, 1.02}], 
Hue[0.6], 
            Rectangle[{0.6, 0.7}, {1, 
                1}]
}], 
PlotRange -> 
          All, ImageSize -> {500, 400}];

You can further dress up a graphic with additional graphics primatives as I do in the next cell.

rect1 = 
        Line[{{0, 0}, {0, 1.05}, {1.05, 1.05}, {1.05, 0}, {0, 
              0}}];
\(\(rect2 = 
Line[{{0.6, 0.6}, {0.6, 1}, {1, 1}, {1, 
              0.6}, {0.6, 0.6}}];\)
\)
Show[
        Graphics[{
Rectangle[{0, 0}, {1.02, 1.02}, gr1], 
            Rectangle[{0.6, 0.7}, {1, 1}, gr2], rect1, rect2}], 
        PlotRange -> All, ImageSize -> {500, 400}];

The third argument given to Rectangle doesn't need to have the head Graphics.  Any type of Mathematica graphics can be given.  In the next cell one of the rectangles is given Graphics3D as a third argument.

\(\(Block[{$DisplayFunction = Identity}, 
\(gr2 = 
            Plot3D[Sin[x] Exp[y], {x, \(-5\), 5}, {y, \(-2\), 
                2}];\)
];\)
\)
Show[
        Graphics[{
Rectangle[{0, 0}, {1.02, 1.02}, gr1], 
            Rectangle[{0.6, 0.7}, {1, 1}, gr2]}], PlotRange -> All, 
        ImageSize -> {500, 400}];

Scaled

Scaled is explained in the section for Offset, Scaled.

Shading

Shading is an option for Graphics3D, SurfaceGraphics and funtions that return Graphics3D or SurfaceGraphics. The default setting is (Shading->True) in which case polygons are colored as determined by simulated Lighting or the ColorFunction.  The HiddenSurface option is used to render the surface as a transparent mesh.

Options[SurfaceGraphics, Shading]
Options[Graphics3D, Shading]

Plot3D[Exp[-((x^4) + (y^4))], {x, -2, 2}, {y, -2, 2}, 
        Shading -> True];
Plot3D[Exp[-((x^4) + (y^4))], {x, -2, 2}, {y, -2, 2}, 
        Shading -> False];

SphericalRegion  (incomplete)

SphericalRegion is an option for Graphics3D, SurfaceGraphics and funtions that return Graphics3D or SurfaceGraphics.

Options[SurfaceGraphics, SphericalRegion]
Options[Graphics3D, SphericalRegion]

<< RealTime3D

Plot3D[x^2 + y^2, {x, 0, 2}, {y, 0, 2}];

Options[Plot3D, SphericalRegion]

SurfaceColor

The usage message for SurfaceColor is shown below.

?SurfaceColor

Further explanation can be found under SurfaceColor  in the HelpBrowser and section  2.9.12 of The Mathematica Book.  The Mathematica lighting model accounts for difuse light reflection, and specular light reflection. The SurfaceColor directive is used to specify the type of reflection for  Graphics3D primitives.

Difuse Reflection

The default lighting model in Mathematica uses only difuse reflection. With difuse reflection light is equally dispursed in all directions such as the light reflected from cloth or flat paint. When SurfaceColor is used with one argument only difuse reflection is used. 

An example is given below to demonstrate the effect of difuse lighting, but first the next cell should be evaluated to make the graphics of a surface with a slight curve shown  at four slightly different views.

SetOptions[Plot3D, 
        DisplayFunction :> $DisplayFunction];
SetOptions[Graphics3D, 
        DisplayFunction :> $DisplayFunction];

Block[{$DisplayFunction = Identity}, 
plt1 = 
        Graphics3D[
          Plot3D[Cos[((x^2) + (y^2))/7], {x, -1, 1}, {y, -1, 
              1}, 
Axes -> False, Mesh -> False, 
            Boxed -> False, PlotPoints -> 70, 
            LightSources -> {{{0, 1, 1.03}, Hue[0.1, 0.1, 1]}} , 
            BoxRatios -> Automatic]]; 
plt2 = 
        Show[plt1, 
          ViewPoint -> {1.1, -2.4, 2.0}]; 
plt3 = 
        Show[plt1, 
          ViewPoint -> {1.3, -2.6, 2.0}]; 
plt4 = 
        Show[plt1, 
          ViewPoint -> {1.3, -2.4, 
              1.0}];
]

The next cell shows the four views above with only difuse reflection.  Notice essentially the same color is reflected from different areas on the surface.  However, the right most view shows the surface with a lighter shade as a result of the way the surface is oriented relative to the light source.

difuse1 = 
        Insert[plt1, 
SurfaceColor[GrayLevel[1]], {1, 
            1}];

difuse2 = 
        Insert[plt2, 
SurfaceColor[GrayLevel[1]], {1, 
            1}];

difuse3 = 
        Insert[plt3, 
SurfaceColor[GrayLevel[1]], {1, 
            1}];

difuse4 = 
        Insert[plt4, 
SurfaceColor[GrayLevel[1]], {1, 
            1}];

Show[
        GraphicsArray[{{difuse1, difuse2, difuse3, 
              difuse4}}], 
DisplayFunction -> $DisplayFunction, ImageSize -> {400, 100}];

Computing the color of difuse reflected light

When the SurfaceColor directive has one argument only difuse reflection is used.  If that argument is GrayLevel[g] then the red, green, and blue components of light reflected from each light source is the red, green, blue components of the incident light times (g Cos[α]) where α is the angle between (the vector normal to the surface of a polygon) and (the direction of the incident light beam).  If the only argument in SurfaceColor is RGBColor[r,g,b] then the red, green, blue compenets of reflected light for each light source are proportional to ( r Cos[α] ), (g Cos[α] ), (b Cos[α] ) respectively.  It seems the only color directives that can be used in SurfaceColor are GrayLevel and RGBColor.

Sepcular Reflection

Mathematica can also model specular reflection where reflected light is concentrated in one direction. A practical example of something that reflects light in this manner is the crome plated bumper on a car.  When SurfaceColor has two or three arguments the first argument specifies the amount of difuse reflection and the second argument specifies the amount of specular reflection. 

The next cell shows the same graphics that were used above with specular reflection but no difuse reflection. In the view on the left light is only reflected from a spot in the center of the graphic. When a different ViewPoint is used light is reflected from a different spot on the surface.  In the right most view the surface is oriented such that no specular reflection is visible.

specular1 = 
Insert[plt1, 
          SurfaceColor[GrayLevel[0], GrayLevel[1], 19000], {1, 
            1}];
specular2 = 
Insert[plt2, 
          SurfaceColor[GrayLevel[0], GrayLevel[1], 19000], {1, 
            1}];
specular3 = 
Insert[plt3, 
          SurfaceColor[GrayLevel[0], GrayLevel[1], 19000], {1, 
            1}];
specular4 = 
Insert[plt4, 
          SurfaceColor[GrayLevel[0], GrayLevel[1], 19000], {1, 
            1}];

Show[
        GraphicsArray[{{specular1, specular2, specular3, 
              specular4}}], 
DisplayFunction -> $DisplayFunction, ImageSize -> {400, 100}];

Computing the color of Specular reflected light

The red, green, and blue components of difuse reflection and specular reflection from each light source are combined to determine the color used for rendering each polygon. The second argument in SurfaceColor specifies the type of specular reflection. Suppose the second argument of SurfaceColor is GrayLevel[g] and the third argument is n (a positive Real, Integer, or Rational).  In that case the red, green and blue components of specular reflected light are the red, green, blue components of incident light times (g Cos[θ]^n) where θ is the angle between (the direction the polygon is veiwed from) and (the direction in which light would reflect if the surface was a perfect mirror).  However, there is no specular reflection when θ is 90° or greater. If the second argument in SurfaceColor is RGBColor[r,g,b] then the red, green, and blue compenets of specular reflected light for each light source are proportional to ( r ((Cos[θ] )^n)), (g ((Cos[θ] )^n)), (b ((Cos[θ] )^n)).  Here too no light is reflected for θ>90°. When SurfaceColor has only two arguments the default value n=1 is used for the third argument.  It seems the only color directives that can be used in SurfaceColor are GrayLevel and RGBColor.

Examples using a Torus

In the cells that follow a torus is shown using different SurfaceColor directives.  First the next cell should be evaluated so the graphic of a torus can be made.

<< Graphics`Shapes`

The next cell makes a torus and displays it with the default lighting effects.

t1 = Torus[1.5, 0.5, 30, 30];
Show[Graphics3D[{EdgeForm[], t1}], 
        ImageSize -> {300, 250}];

In the next cell the SurfaceColor specified has one argument which causes the Torus to come out like the one from the previous cell except a little gray.  The color used for each polygon is determined by multiplying the each component (red, green, blue) of the incident light from each light source by 0.87 Cos[α] where α is the angle between (the vector normal to the surface of a polygon) and (the direction of the incident light beam).

gr1 = {EdgeForm[], SurfaceColor[GrayLevel[0.87]], t1};
Show[Graphics3D[{gr1}], ImageSize -> {300, 250}];

In the next cell SurfaceColor has one argument (an RGBColor).   Here again only difuse reflection is used, and the Torus comes out green. In this case the color used for each polygon is determined by multiplying each component (red, green, blue) of the incident light by 0.4 Cos[α],  Cos[α] , 
      0.4 Cos[α] respectively.  This is done for each light source and the reflected light form each source is combined to give the total effect.

gr1 = {EdgeForm[], SurfaceColor[RGBColor[0.4, 1, 0.4]], 
          t1};
Show[Graphics3D[{gr1}], ImageSize -> {300, 250}];

In the next cell difuse reflection is used to make the Torus look red.  Here the calculation of the color for each polygon is similar to that used in the last example.

gr1 = {EdgeForm[], SurfaceColor[RGBColor[1, 0.3, 0.2]], 
          t1};
Show[Graphics3D[{gr1}], ImageSize -> {300, 250}];

When SurfaceColor is given two arguments the first argument indicates the color and amount of difuse reflection to use, and the second argument indicates the color and amount of specular reflection to use. In the next cell the first argument of SurfaceColor the black (GrayLevel[0]).  This causes the use of no difuse lighting, and all reflection of light is governed by the second argument which specifies the specular reflection. The second argument in SurfaceColor causes the intensity of the red, green, blue components of light reflected from each polygon to be proportional to Cos[θ],  0.3 Cos[θ] , 
      0.2 Cos[θ] respectively.  As discussed above θ is the angle between (the direction the polygon is veiwed from) and (the direction in which light would reflect if the surface was a perfect mirror), except if θ is 90° or greater there is no specular reflection.

gr1 = {EdgeForm[], SurfaceColor[GrayLevel[0], RGBColor[1, 0.3, 0.2]], 
          t1};
Show[Graphics3D[{gr1}], ImageSize -> {300, 250}];

The next cell is the same as the last cell except for the third argument in SpecularColor. In this case the third argument in SurfaceColor is 3, so the intensity of the red, green, blue components of light reflected from each polygon is proportional to Cos[θ]^3,   0.3 Cos[θ]^3,  
      0.2 Cos[θ]^3 respectively.

gr1 = {EdgeForm[], 
          SurfaceColor[GrayLevel[0], RGBColor[1, 0.3, 0.2], 3], 
          t1};
Show[Graphics3D[{gr1}], ImageSize -> {300, 250}];

The next cell combines the effects of some of the previous examples.  In this case we have green difuse reflection and red specular reflection.  Where both types of reflection are present green and red combine to make yellow.

gr1 = {EdgeForm[], 
          SurfaceColor[RGBColor[0.4, 1, 0.4], RGBColor[1, 0.3, 0.2], 3], 
          t1};
Show[Graphics3D[{gr1}], ImageSize -> {300, 250}];

The next two cells use a higher and lower value for the third argument in SurfaceColor.  This gives a larger or smaller region with yellow reflection.

gr1 = {EdgeForm[], 
          SurfaceColor[RGBColor[0.4, 1, 0.4], RGBColor[1, 0.3, 0.2], 5], 
          t1};
Show[Graphics3D[{gr1}], ImageSize -> {300, 250}];

gr1 = {EdgeForm[], 
          SurfaceColor[RGBColor[0.4, 1, 0.4], RGBColor[1, 0.3, 0.2], 1.8], 
          t1};
Show[Graphics3D[{gr1}], ImageSize -> {300, 250}];

The next cell shows three Torus in the same graphic using the default SurfaceColor.

s1 = Torus[1.5, 0.5, 30, 30];
s2 = Torus[2.25, 0.75, 30, 30];
t1 = 
        TranslateShape[
          RotateShape[s2, 0, π/2, π/2], {-2, 0, 
            0}];
t2 = TranslateShape[s1, {0, 0, -3}];
Show[
        Graphics3D[{{EdgeForm[], t1}, {EdgeForm[], s1}, {EdgeForm[], 
              t2}}]];

In the next cell we can combine objects using different specifications for SurfaceColor.  The next example shows the same three Torus as the last example, but this time they each have a different SurfaceColor.

gr1 = {EdgeForm[], 
          SurfaceColor[RGBColor[0.4, 1, 0.4], RGBColor[1, 0.3, 0.2], 4], 
          t1};
gr2 = {EdgeForm[], SurfaceColor[RGBColor[1, 0.3, 0.2], GrayLevel[0]], 
          s1};
gr3 = {EdgeForm[], SurfaceColor[GrayLevel[1], GrayLevel[1], 6], 
          t2};
Show[Graphics3D[{gr1, gr2, gr3}]];

SurfaceColor for SurfaceGraphics

If we want to use SurfaceColor when showing Graphics3D as in
     Show[Graphics3D[{SurfaceColor[___], s }]]
Then we should provide (s) which is a list of polygons.  Actually SurfaceColor can affect the lighting of Cuboids as well, but we won't look into that right now.  Suppose you want to use SurfaceColor with the graphics produced by Plot3D in the next cell.

plt1=Plot3D[Sin[x y],{x,0.5,2.5},{y,0.5,2.5}];

The expression returned by Plot3D has the head SurfaceGraphics.  By using Graphics3D[plt1] we can convert the SurfaceGraphics to Graphics3D.  We can then insert a SurfaceColor directive at the appropriate position if we don't want to use the default surface.

gr4=Insert[Graphics3D[plt1],SurfaceColor[RGBColor[0,0.3,0.6],RGBColor[0,0.7,0.3],2],{1,1}];
Show[gr4];

We can even combine the graphics from Plot with a Torus that uses a specified SurfaceColor as in the next cell !

t1 = 
        TranslateShape[
          Torus[0.45, 0.1, 30, 30], {1.8, 1.8, 
            0}];
rng = 
        PlotRange /. 
          AbsoluteOptions[plt1, PlotRange];
gr5 = Insert[Graphics3D[plt1], {EdgeForm[], t1}, {1, 1}];
Show[gr5, PlotRange -> rng];

Text

The typical use of text is straight forward.  However, one must do some very tricky stuff to display framed text in Graphics or Graphics3D.  Alan Hayes showed how this can be done in response to a question in the MathGroup.  The next cell demonstrates Alan's solution.  I would elaborate on how it works, but I don't understand it myself.

\(\(\(txt2 = 
        Graphics[
Text[
            DisplayForm[
              FrameBox[
FormBox[
                  StyleBox[
                    MakeBoxes[ρ\  = \ k\ r^2, 
                      TraditionalForm], 
FontWeight -> "Bold", FontSize -> 24], TraditionalForm]]
], {5, 
              1/2}]];\)\(
\)
    \)\)
Block[{$DisplayFunction = Identity}, 
plt2 = 
          Plot[ Sin[x], {x, 0, 2  π}]
];
Show[{plt2, txt2}];

The next cell does the same thing with Graphics3D.

\(\(\(txt1 = 
        Graphics3D[
Text[
            DisplayForm[
              FrameBox[
FormBox[
                  StyleBox[
                    MakeBoxes[ρ\  = \ k\ r^2, 
                      TraditionalForm], 
FontWeight -> "Bold", FontSize -> 24], TraditionalForm]]
], {3, 
              3, 0}]];\)\(
\)
    \)\)
Block[{$DisplayFunction = Identity}, 
plt1 = 
          Plot3D[Cos[x] Sin[y], {x, 0, 2  π}, {y, 0, 
              2  π}, 
PlotPoints -> 40, 
            Mesh -> False]
];
Show[{plt1, txt1}];

Ticks

The next line gives a plot with manually specified ticks on the horizontal axis.

\(\(Plot[x\^2, {x, 0, 3}, 
	
        Ticks -> {{1, 2, 3}, 
		Automatic}];\)\)

Next we have a plot with manually specified ticks where some of the ticks have no label.

\(\(Plot[x\^2, {x, 0, 3}, 
	
        Ticks -> {
			{{0.5, ""}, {1, 1}, {1.5, ""}, {2, 
                2}, {2.5, ""}, {3, 3}}, 
		Automatic}];\)\)

The next line makes a plot with manually specified ticks where some of the ticks have no label and the height of each tick is specified.  In this case one value is given for height and the tick is extended by that distance in the positive and negative directions.

\(\(Plot[x\^2, {x, 0, 3}, 
	
        Ticks -> {
			{{0.5, "", 0.01}, 
				{1, 1, 
                0.03}, 
				{1.5, "", 0.01}, 
				{2, 2, 
                0.03}, 
				{2.5, "", 0.01}, 
				{3, 3, 
                0.03}}, 
		Automatic}];\)\)

The next line uses a list (of two values) for the height of the ticks.  This specifies the height in the positive and negative directions.

\(\(Plot[x\^2, {x, 0, 3}, 
	
        Ticks -> {
			{{0.5, "", {0.01, 0}}, 
				{1, 
                1, {0.02, 0}}, 
				{1.5, "", {0.01, 
                  0}}, 
				{2, 
                2, {0.02, 0}}, 
				{2.5, "", {0.01, 
                  0}}, 
				{3, 
                3, {0.01, 0}}}, 
		Automatic}];\)\)

In the next line the specification a style for some ticks is given (in list braces) after the height specification.

\(\(Plot[x\^2, {x, 0, 3}, 
	
        Ticks -> {
			{{0.5, "", {0.01, 0}}, 
				{1, 
                1, {0.02, 
                  0}, {Thickness[0.01]}}, 
				{1.5, "", {0.01, 
                  0}}, 
				{2, 
                2, {0.02, 
                  0}, {Thickness[0.01]}}, 
				{2.5, "", {0.01, 
                  0}}, 				{3, 
                3, {0.02, 
                  0}, {Thickness[0.01]}}}, 
		Automatic}];\)\)

ViewCenter, ViewPoint, ViewVertical

The next cell creates a graphic we will use to demonstrate ViewCenter, ViewPoint, and ViewVertical.

gr=Graphics3D[{
PointSize[0.05],
 Hue[1], Point[{5, 8, 10}], 
 Hue[0.17], Point[{6, 8, 10}], 
 Hue[0.35], Point[{6, 8, 11}],
 Hue[0.75],Point[{6,9,10}]
 },PlotRange -> {{4.97, 6.03}, {7.97,9.03}, {9.97,11.03}}
 ];
 Show[gr];

"Display Area"
When Mathematica displays any type of graphics the result is displayed in "display area".  Click on the graphic and a box will be displayed around the graphic, and black squares will be shown in each corner of the box and at the center of each side of the box.  You can drag the black squares around to resize the graphic. The area inside this box is the "display area".

"Bounding Box"
By default Graphics3D has the setting (Boxed->True) which ensures a box is drawn around the volume covered by the PlotRange setting.  I call this box around the graphic the "bounding box".

ViewCenter

ViewCenter is an option for Graphics3D, SurfaceGraphics and funtions that return such graphics. The ViewCenter usage message is shown below.

?ViewCenter

The coordinates used for ViewVenter are always scaled so that the bounding box of the graphic has range (0,1) in all three directions.  The default setting is ViewCenter->{0.5,0.5,0.5} which ensures the center of the bounding box in in the center of the display area. Next I use ViewCenter->{0,0,0} and the red point is in the center of the graphic.  Here the red point is in the center of the display area because it's near the lowest value for the range along all three axes.  Recall the red point is at {5,8,10}, the yellow point is at {6,8,10}, the green point is at {6,8,11}, and the purple point is at {6,9,10}.

Show[gr, ViewCenter -> {0, 0, 0}];

In the next cell the green point is near the center of the display area.  That is because the setting ViewCenter->{1,0,1} ensures the maximum value along the x, z axes, and the minimum value along the y axis is in the center of the display area.

Show[gr, ViewCenter -> {1, 0, 1}];

Regardless of what setting for ViewPoint is used, ViewCenter always refers to the same point on the graphic.  So for example the next input ensures the red point is in the center of the display area.

Show[gr, ViewPoint -> {4, 5.2, -2.8}, 
        ViewCenter -> {0, 0, 0}];

The setting (SphericalRegion->True) overrides any ViewCenter setting.

ViewPoint

ViewPointr is an option for Graphics3D, SurfaceGraphics and funtions that return such graphics. The ViewCenter usage message is shown below.

?ViewPoint

For ViewPoint the coordinates of the bounding box have the range (-0.5, 0.5) along each axis.  The ViewPoint option uses this scaled coordinate system to specify the direction form which the graphics are viewed.  The setting of the ViewPoint option must be a point outside the bounding box.  In the next cell we see the default ViewPoint setting.

AbsoluteOptions[gr, ViewPoint]

Because the coordinates used for ViewPoint are scaled to (-0.5,0.5) the viewing angle of the next example is parallel with the left edge and top edge of the bounding box.

Show[gr, ViewPoint -> {2, -0.5, 0.5}];

In the next example the last coordinate of the ViewPoint setting is zero, so our viewing angle is centered along the vertical axis.

Show[gr, ViewPoint -> {2, -0.8, 0}];

The effects of perspective are severe when the ViewPoint is very close to the edge of the bounding box.  In the next example we see what the graphic would look like to a fly who is about to land on the green point.

Show[gr, ViewPoint -> {0.56, -0.59, 0.61}];

In the next example the ViewPoint is far away, and out viewing angle is nearly parallel with the top and bottom surfaces of the bounding box.

Show[gr, ViewPoint -> {18, -4, 0}];

Next we view the graphic from a viewing angle that almost lines up opposite corners of the bounding box.

Show[gr, ViewPoint -> {2, -2.06, 2.26}];

ViewVertical

ViewVertical is an option for Graphics3D, SurfaceGraphics and funtions that return Graphics3D or SurfaceGraphics such graphics. The ViewVertical usage message is shown below.

?ViewVertical

The default ViewVertical setting has the z axis in the vertical direction.  This is clear in the next graphic.

Show[gr, ViewVertical -> {0, 0, 1}, 
        ViewPoint -> {0.85, -6, 0}];

In the next cell we have a ViewVertical setting that has the effect of rotating the bounding box counter-clockwise.  Here we have the setting ViewVertical->{0.1,0,1} and we show an arrow in the direction of the vector {0.1,0,1}.  You will notice the bounding box is rotated to make the arrow pointing straight up.

Show[gr, 
        Graphics3D[{Thickness[0.01], 
            Line[{{5, 8, 10}, {5.08, 8, 
                  10.8}}], 
SurfaceColor[GrayLevel[0]], 
            Polygon[{{5.06, 8, 10.8}, {5.1, 8, 10.8}, {5.08, 8, 
                  10.88}}]
}], 
ViewVertical -> {0.1, 0, 1}, 
        ViewPoint -> {-0.85, -6, 0}];

P. J. Hinton of Wolfram Research provided the amazing solution below to the Math Group which makes a palette with graphics in the buttons.  First we define a list of graphics objects that will appear in the buttons.

grList = {
Plot[Sin[x], {x, 0, 2  π}, 
            DisplayFunction -> Identity], 
Plot3D[
            Sin[x] Cos [y], {x, 0, 2  π}, {y, 0, 2  π}, 
            DisplayFunction -> 
              Identity]
};

Next convert the graphics objects to Mathematica  PostScript strings.

psStringList = Map[DisplayString, grList];

Now create a list of cells containing the graphics at 100 x 100 pixels.

cellExprList = 
        Map[
Cell[
GraphicsData["\
PostScript", #], 
              ImageSize -> {100, 
                  100}] &, 
psStringList];

The next line generates the needed ButtonBoxes. Here the buttons paste copies of the images so the front end automatically determines the size of the pasted image.

btnBoxList = 
Map[
ButtonBox[#, 
ButtonFunction :> (NotebookWrite[
                    InputNotebook[], # /. (ImageSize -> _) -> (ImageSize -> Automatic)])
, 
              ButtonEvaluator -> Automatic, Active -> True] &, 
          cellExprList];

Finally a cell with buttons containing the graphics in a RowBox strcuture is created.  Pressing one of the buttons pastes a copy of the graphic in the notebook.

CellPrint[Cell[BoxData[RowBox[btnBoxList]]]]

In Mathematica graphic primitives are nouns, and graphic directives are adjectives.  That is the the directives specify what the primitives look like.

The graphics primitives (2D) for use in Graphics[{__}] are
     Line, Point, Polygon, Text, Rectangle, Circle, Disk, Raster, RasterArray.

The graphics primitives (3D) for use in  Graphics3D[{__}] are
     Line, Point, Polygon, Text, Cuboid.
     
The directives available for specifying Graphics and Graphics3D primitives are:
    Thickness, PointSize, Dashing, AbsoluteThickness, AbsolutePointSize, AbsoluteDashing, RGBColor, Hue, GrayLevel, CMYKColor.

In addition the following directives are available for Graphics3D primitives:
    SurfaceColor, EdgeForm, FaceForm

The first argument in Graphics, or Graphics3D must be a suitable graphics primitive, or a list of such primatives. If a list of primitives is used, graphic directives can be included.  A graphics directive affects all relavent primitives that come after the directive until another directive is given to override the earlier directive.

For example in the next cell the first point, circle and line are drawn using the default directives.  The second circle and line are thicker due to the directive Thickness[0.02].  Also the second point is larger due to the directive PointSize[0.02]. The third point, circle and line are red due to the directive RGBColor[1,0,0] but the earlier directives for Thickness and PointSize still apply. Then for the fourth point, circle and line are green because the earlier color directive is overridden by the directive Hue[0.3]. In addition the directive AbsolutePointSize[20] makes the fourth point even larger than the points before it. However, the fourth circle and line are the same thickness as the third circle and line because there is no directive to override the earlier thickness. Finally the last circle and line are thinner due to the directive AbsoluteThickness[1], but they have the same color as the circle and line that preceeded them because the earlier directive wan not overridden.  Likewise the last point is the same size as the fourth point because there is no overridding directive.

example=Graphics[{
Point[{0.5, 0.5}],
Circle[{0.5, 0.5}, 0.3],
Line[{{1, 0}, {1, 1}}],
Thickness[0.02],PointSize[0.02],
Point[{1.5, 0.5}],
Circle[{1.5, 0.5}, 0.3],
Line[{{2, 0}, {2, 1}}],
RGBColor[1, 0, 0],
Point[{2.5, 0.5}],
Circle[{2.5, 0.5}, 0.3],
Line[{{3, 0}, {3, 1}}],
Hue[0.3],AbsolutePointSize[20],
Point[{3.5, 0.5}],
Circle[{3.5, 0.5}, 0.3],
Line[{{4, 0}, {4, 1}}],
AbsoluteThickness[1],
Point[{4.5, 0.5}],
Circle[{4.5, 0.5}, 0.3],
Line[{{5, 0}, {5, 1}}]
}];
Show[example, 
        PlotRange -> {{0, 5.2}, {0, 1}}, Axes -> True, 
        AspectRatio -> Automatic, 
        ImageSize -> {600, 150}];

The different type of Mathematica graphics include Graphics, Graphics3D, SurfaceGraphics, DensityGraphics, and ContourGraphics.  Mathematica allows one to easily make the following conversions on SurfaceGraphics, ContourGraphics, and DensityGraphics.
 
SurfaceGraphics[…] ⟹ DensityGraphics[…]
SurfaceGraphics[…] ⟹ ContourGraphics[…]
SurfaceGraphics[…] ⟹ Graphics3D[…]
 
ContourGraphics[…] ⟹ DensityGraphics[…]
ContourGraphics[…] ⟹ SurfaceGraphics[…]
ContourGraphics[…] ⟹ Graphics[…]
 
DensityGraphics[…] ⟹ ContourGraphics[…]
DensityGraphics[…] ⟹ SurfaceGraphics[…]
DensityGraphics[…] ⟹ Graphics[…]

To see how simple this is consider the next cell which makes a course DensityPlot, and displays the underlying expression for the graphic.  You will notice the underlying expression is simply the head DensityGraphics with a matrix of real numbers and a list of options.

DensityGraph = 
        DensityPlot[Sin[x  y], {x, 0, 3}, {y, 0, 3}, 
          PlotPoints -> 5];
InputForm[DensityGraph]

In the next cell we simply evaluate SurfaceGraphics[DensityGraph]  to change the above DensityGraphic to SurfaceGraphics.  This cell also shows the SurfaceGraphics and returns the underlying expression of the SurfaceGraphics.  Notice to the underlying expression is very similar to the one for DensityGraph.  We only changed the head to SurfaceGraphics, and made some minor changes to the options. Switching between SurfaceGraphics, DensityGraphics, and ContourGraphics is trivial because the three type of graphics have the same underlying form.

SurfaceGraph = 
        SurfaceGraphics[DensityGraph];
Show[SurfaceGraph];
InputForm[SurfaceGraph]

In the next cell we simply evaluate  Graphics3D[SurfaceGraph]  to change the above SurfaceGraphics to Graphics3D.  This cell also shows the SurfaceGraphics and returns the underlying expression of the Graphics3D.  The result we get back has the form Graphics3D[{primatives},  options].  While the graphic rendered below is the same we get from Show[SurfaceGraph], we could combine the Graphics3D primitives below with other primitives in ways that aren't possible with SurfaceGraphics.

Graph3Dim = Graphics3D[SurfaceGraph];
Show[Graph3Dim];
InputForm[Graph3Dim]

In the next cell we simply evaluate  Graphics[DensityGraph]  to change the above DensityGraphics to Graphics primitives.  This cell also shows the Graphics and returns the underlying expression.  The result we get back has the form Graphics[{primatives},  options].  While the graphic rendered below is the same we get from Show[DensityGraph], we could combine the Graphics primitives below with other primitives in ways that aren't possible with DensityGraphics.

gr = Graphics[DensityGraph];
Show[gr];
InputForm[gr]

Sometimes one might want to display a graphic such that only the portion inside a circle with a certain radius is displayed. The plot of a Sin wave below will be used as an example where only the portion of the graphic inside a circle centered at the origin with radius 0.85 is displayed.

curve = Plot[Sin[75 t], {t, -1, 1}];

The graphic made by the next cell is used to demonstrate how one can hide the portion of the above plot outside the desired circle.

circ = 
        ParametricPlot[{0.85*Cos[t], 0.85*Sin[t]}, {t, 0.03, 
            2  π - 0.03}, 
DisplayFunction -> 
            Identity, PlotPoints -> 9, 
          PlotDivision -> 
            1];

pnts = 
        Join[Part[circ, 1, 1, 1, 
            1], 
{{1.1, -0.03}, {1.1, -1.1}, {-1.1, -1.1}, {-1.1, 1.1}, {1.1, 1.1}, {1.1, 
              0.03}} 
];

mask = 
        Graphics[{GrayLevel[0.7], 
            Polygon[pnts]}];

Show[mask, AspectRatio -> Automatic, 
        PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}}, 
        Axes -> True];

The next input displays the mask from above on-top of the Sin wave made earlier.

Show[curve, mask, AspectRatio -> Automatic, 
        PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}}, 
        Axes -> True];

The next cell makes a circle with lots of points, and ensures the mask covers the whole circle.

circ = 
        ParametricPlot[{0.85*Cos[t], 0.85*Sin[t]}, {t, 0, 
            2  π}, 
DisplayFunction -> 
            Identity];

pnts = 
        Join[Part[circ, 1, 1, 1, 
            1], 
{{1.1, 
              0}, {1.1, -1.1}, {-1.1, -1.1}, {-1.1, 
              1.1}, {1.1, 1.1}, {1.1, 
              0}} 
];

mask = 
        Graphics[{GrayLevel[0.7], 
            Polygon[pnts]}];

Show[curve, mask, AspectRatio -> Automatic, 
        PlotRange -> {{-1, 1}, {-1, 1}}, 
        Axes -> True];

In the next cell the mask is invisible since it's the same color as the bacgkround.

mask = 
        Graphics[{GrayLevel[1], 
            Polygon[pnts]}];

Show[curve, mask, AspectRatio -> Automatic, 
        PlotRange -> {{-1, 1}, {-1, 1}}, 
        Axes -> True];

When making frames for an animation it's convenient to have all the frames of the animation grouped together with all but the first frame closed.  The code in the next cell does this automatically.  This solution was sent to the MathGroup by  (adam.smith@hillsdale.edu).

Do[
        Plot[Sin[2 π  (t + n/25)], {t, 0, 1}], {n, 1, 
          25}];
SelectionMove[EvaluationNotebook[], All, 
        GeneratedCell];
FrontEndTokenExecute["CellGroup"]
FrontEndTokenExecute["OpenCloseGroup"]

It's not uncommon for Graphic command such as Plot to produce a series of annoying error messages. This typically happens when one makes a typo as in the next cell.

Plot[BeselJ[1, x], {x, 0, 4}];

Plot and several other graphic functions will no longer  do this if you evaluate the cell below.

\(Off[ContourPlot::plnr, DensityPlot::plnr, Plot::plnr, Plot3D::plnc, 

      Plot3D::gval, ParametricPlot::pptr, ParametricPlot3D::pplr]\)

You can include the code above in your (init.m) file and Mathematica will automatically turn off these messages when the kernel is launched.

Consider several attempts to plot the derivative of f[x] below.

f[x_] = Sum[Sin[n x]/n,  {n, 20}];

This first attempt doesn't work at all.

Plot[D[f[x], x],  {x, 0, 8}];

The second attempt works, but takes over 11 seconds, because the derivative is derived for every sample point.

Plot[f'[x],  {x, 0, 8}];

The best version is below,and takes a little more than 1 second.  It works much faster because the derivative is worked out only once (before the derivative is sampled).

Plot[Evaluate[f'[x]], {x, 0, 8}];