5
$\begingroup$
Plot3D[Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2},   ColorFunction -> (ColorData["VisibleSpectrum"][
     Rescale[#3, {0, 1}, {380, 750}]] &), PlotLegends -> Automatic]

enter image description here

There is no legend in this picture.

Plot3D[Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2}, 
 ColorFunction -> (ColorData["VisibleSpectrum"][Rescale[#3, {0, 1}, {380, 750}]] &), 
 PlotLegends -> BarLegend[{"VisibleSpectrum", {0, 1}}]]

enter image description here

BarLegend["VisibleSpectrum"]

enter image description here

The color of lengend is wrong.

Mathematica 10.0.1. Is this a bug?

$\endgroup$
  • $\begingroup$ I think the correct usage of the second argument should be BarLegend[{"VisibleSpectrum", {380, 750}}] but no, that doesn't work either... $\endgroup$ – C. E. Nov 24 '14 at 5:19
  • $\begingroup$ related: 38895. @Pickett almost :) see my answer. $\endgroup$ – Kuba Nov 24 '14 at 7:22
  • $\begingroup$ @Kuba wow, I only tried BarLegend on its own. You can't even set the scaling then as far I as I know. I count this as a bug.. $\endgroup$ – C. E. Nov 24 '14 at 12:09
8
$\begingroup$
f@x_ := ColorData["VisibleSpectrum"][Rescale[x, {0, 1}, {380, 750}]]; 
Plot3D[
 Exp[-x^2 - y^2], {x, -2, 2}, {y, -2, 2},
 ColorFunction -> f, PlotLegends -> BarLegend[{f@# &, {0, 1}}]]

Mathematica graphics

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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