Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This has a connection to the previous post here: puzzled with a color function Also, a recent post of mine appeared here: Create a color bar plot legend but I should have solved the problem with the color function before asking the question about color bar. If opening a new thread goes against the forums policies I apologize.

Thanks to the answers I got, I have now what I wanted

h = ParametricPlot3D[lst, {u, 0, 2*Pi}, {v, 0, Pi}, Mesh -> False, 
    ColorFunction -> (Function[{x, y, z, u, v}, Hue[Rescale[dam, {0, 1}]]]), 
    ColorFunctionScaling -> False, ImageSize -> 800];
g = Plot3D[Rescale[dam, {0, 1}], {u, 0, 2*Pi}, {v, 0, Pi}, Mesh -> False, 
    ColorFunction -> (Function[{u, v, z}, Hue[Rescale[dam, {0, 1}]]]), 
    ColorFunctionScaling -> False, PlotRange -> All];
Row[{h, Show[g, ImageSize -> 400]}]

What I further want is to add a color bar to each plot. Something like

Legended[h, BarLegend[{colFun,{min,max}}]] (*version 9*)

which does not give the requested color bar.

Also,

colourBar = 
  DensityPlot[y, {x, 0, 1}, {y, 0, 1}, AspectRatio -> 5, 
   PlotRangePadding -> 0, 
   FrameTicks -> {{None, Range[0, 1, 0.1]}, {None, None}}, 
   ColorFunction -> colFun];
Row[{Show[gr1, ImageSize -> Large], 
  Show[colourBar, ImageSize -> Small]}] (*vesrion 8 alternative*)

does not work as well.

Thanks in advance for any advice.

Dimitris

share|improve this question

1 Answer 1

{min, max} ={-10, 10};
h2 = ParametricPlot3D[lst, {u, 0, 2*Pi}, {v, 0, Pi}, Mesh -> False, 
     ColorFunction -> (Function[{x, y, z, u, v}, Hue[Rescale[dam, {0, 1}]]]), 
     ColorFunctionScaling -> False, 
     ImageSize -> 800, 
     PlotLegends -> BarLegend[{Hue, {min, max}}, ColorFunctionScaling -> True]]

enter image description here

or

Legended[h, BarLegend[{Hue, {min, max}}, ColorFunctionScaling -> True]]

Using Hue instead of colFun as the ColorFunction setting in your colourBar gives something that you can use as the second argument of Legended in version 8:

colourBar2 = DensityPlot[v, {u, 0, 1}, {v, min, max},
                       ColorFunction -> Hue,
                       AspectRatio -> 10, Frame -> True, PlotRangePadding -> 0, 
                       ImagePadding -> 25,
                       FrameTicks -> {False, Automatic, False, Automatic}]

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.