# Maximum and minimum plotted on a curve

Through code:

f[{x_, y_, z_}] = x^4 + y^4 + z^4;

r[t_] = {1/3 + 1/3 Cos[t] - 1/Sqrt[3] Sin[t],
1/3 + 1/3 Cos[t] + 1/Sqrt[3] Sin[t],
1/3 - 2/3 Cos[t]};
{min, max} = {0, 2 Pi};

ParametricPlot3D[
r[t],
{t, min, max},
ColorFunction -> Function[t,
ColorData["Rainbow"][f[r[t]]]],
AxesLabel -> {x, y, z},
BoxRatios -> {1, 1, 1},
PlotLegends -> BarLegend[{"Rainbow",
{MinValue[{f[r[t]], min <= t <= max}, t],
MaxValue[{f[r[t]], min <= t <= max}, t]}}]]


I get:

which it is certainly not what you want, because through this other code:

f[x_, y_, z_] = x^4 + y^4 + z^4;

A = ImplicitRegion[x^2 + y^2 + z^2 <= 1 && x + y + z <= 1, {x, y, z}];

SliceDensityPlot3D[
f[x, y, z],
BoundaryDiscretizeRegion[A],
{x, y, z} \[Element] DiscretizeRegion[A],
ColorFunction -> "Rainbow",
AxesLabel -> Automatic,
PlotLegends -> Automatic]


I get:

where the colors are very clear that it must be expected on the circumference above.

Where am I wrong?

• Which minimum should be colored? Minimum t, min x, y, z, min length to point p/origin? (And try: ColorFunctionScaling -> False) Jan 25, 2017 at 22:38
• Btw, note that your definition of functions should use SetDelayed if you define variables as patterns: f[x_,y_,z_]:=... Jan 26, 2017 at 0:27

By default, color data is scaled such that it uses the entire range of the applied color function. To avoid this, set ColorFunctionScaling->False. Furthermore, ColorFunction, according to the documentation, should be a function of x,y,z,u (where u is t in your code). So here is the full call:

ParametricPlot3D[r[t], {t, min, max},
ColorFunction ->
Function[{x, y, z, t}, ColorData["Rainbow"][f[r[t]]]],
ColorFunctionScaling -> False, AxesLabel -> {x, y, z},
BoxRatios -> {1, 1, 1},
PlotLegends ->
BarLegend[{"Rainbow", {MinValue[{f[r[t]], min <= t <= max}, t],
MaxValue[{f[r[t]], min <= t <= max}, t]}}]]


• @Manu: see updated code Jan 26, 2017 at 0:24