Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Plot scalar fields on surfaces with legends' topicStudent Support Forum > General > Archives > "Plot scalar fields on surfaces with legends"

Help | Reply To Topic
Author Comment/Response
TM
09/04/12 10:33am

Hi everyone

I am a new user of Mathematica and I would like to plot a scalar field on a surface with a color legend.

For example I would like to plot the scalar field f[x,y,z]=x^2+y^2+z^2 on the surface defined by z = Sin[xy] for 0x<5 and 0<y<5 with a color legend which automaticaly scale from the min to the max of f[x,y,z] (with colors from blue to red if possible)

I tried this

Needs["PlotLegends`"];
ShowLegend[
Plot3D[Sin[x y], {x, 0, 5}, {y, 0, 5}, ColorFunction -> Function[{x, y, z}, Hue[x^2 + y^2 + z^2]]
],
{
ColorData["Rainbow"][#] &, 20, " 1", "-1",
LegendPosition -> {1.1, -0.6}
}]

But the Hue[] function scales everything in [0,1] and the color legend is not automatically generated (I put manually 1 and -1).

Does anyone know how to solve this problem?

Best regards
TM

URL: ,
Help | Reply To Topic