Color - Which way is up?

Another important method for encoding data is by color.  Of course, unlike time where order is usually obvious, color presents a real problem of interpretation.  Which color is "first" or "smallest"?  If  you use color, you have to make this clear.  If you want to look this up in the Help browser, you can learn about this in detail, but here is a relatively simple way to assign a color to a variable in some types of graphs.  (I have chosen to use Grayscale rather than color actually, since it becomes relatively easy to assign an obvious order to those.  Feel free to experiment with other options, if you enjoy that sort of thing...)

In some cases, Mathematica uses colors automatically:

ContourPlot[x^2 + y^2, {x, -10, 10}, {y, -10, 10}]

[Graphics:../HTMLFiles/index_142.gif]

⁃ContourGraphics⁃

In Plot3D and ParametricPlot3D, you can specify an extra list element (like an extra dimension to the range vector) with a color specification.  One important catch here is that you can only specify GrayLevel values between 0 and 1, so you have to be sure you scale that "variable" accordingly.  (This is a pain, since it varies with the domain, but not really a serious restriction in displaying your data.)

Plot3D[{Sin[x y], GrayLevel[Sin[x + y]^2]}, {x, -π, π}, {y, -π, π}, PlotPoints50]

[Graphics:../HTMLFiles/index_145.gif]

⁃SurfaceGraphics⁃

So, in this case, the color depends on Sin[x + y]^2.  In a parametric graph (curve or surface), you can just list a fourth component to your range vector:

ParametricPlot3D[{t, Sin[t], Cos[t], GrayLevel[t/(4π)]}, {t, 0, 4π}, LightingFalse, BackgroundSkyBlue]

[Graphics:../HTMLFiles/index_149.gif]

⁃Graphics3D⁃

joe = ParametricPlot3D[{u Sin[v], -u Cos[v], u, GrayLevel[1 - v^2/π^2]}, {v, -π, π}, {u, 0, 5}, LightingFalse]

[Graphics:../HTMLFiles/index_152.gif]

⁃Graphics3D⁃

Two important notes about this:

In ParametricPlot3D, it is important to set Lighting→False to show the colors properly.  (Oddly enough, you must not do that in Plot3D.)

Unfortunately, there is still a bug in the RealTime3D module that will not pass on color information properly, so to make this work, you must not have RealTime3D loaded.  (If it is loaded already, you can unload it by <<Default3D`)


Created by Mathematica  (February 28, 2007) Valid XHTML 1.1!