I've been trying to get BarLegend to work with Mathematica's Plot3D coloring example function. I wanted to use coloring to indicate the height of the function, and the Plot3D documentation provides this as an example:
Plot3D[x/Exp[x^2 + y^2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> Function[{x, y, z}, Hue[.65 (1 - z)]]] I have my own function and domain, but I copied Mathematica's coloring function directly:
Plot3D[{3.5 Log[1.7*x^3 + 0.8*Sin[y] +3]}, {x, 1, 100}, {y, 10^-5, 1}, ColorFunction -> Function[{x, y, z}, Hue[.65 (1 - z)]]] The problem occurs when I try to create a legend for the coloring. None of the following works:
BarLegend[ColorFunction -> Function[{x, y, z}, Hue[.65 (1 - z)]]], BarLegend[Function[{x, y, z}, Hue[.65 (1 - z)]]], BarLegend[Hue[.65 (1 - z)]] I did a bit of reading on this site, and the best I could find was the following. I can manually find the minimum and maximal values that the function takes on my domain of interest:
minmax = {5.41647, 50.2115}; BarLegend[{Function[x, Reverse@Hue[0.65 Rescale[x, minmax]]], minmax}]
(sorry the resizing for this image isn't working)
This gets a bit closer to what I want, but the legend is flipped upside down (I am also not certain that the ticks/numbers are exactly correct).
Would you know how to fix this/get the right legend to appear?
Thank you!



