4
$\begingroup$
$Version
DensityPlot3D[x y z
 , {x, -1, 1}, {y, -1, 1}, {z, -1, 1}
 , ColorFunction -> Hue
 , ImageSize -> 200
 , PlotLegends -> {BarLegend[Hue
    , LegendMarkerSize -> {30, 180}]
   }
 ]

enter image description here

Question

  1. What is the proper name for the gray area to the left of BarLegend? My guess is that it is trying to convey the range of colors used in the plot.

  2. A Legended plot does not have this gray area (just a BarLegend). Is this a feature of PlotLegends?

  3. Is there an option to turn it off?

  4. Is there an option to change its width and/or style?

  5. Any link to its documentation would be appreciated.

Thanks for your help.

$\endgroup$
1
  • 1
    $\begingroup$ It's the opacity of the color. See Details and Options in DensityPlot3D. $\endgroup$
    – Domen
    Sep 4 at 10:36

1 Answer 1

7
$\begingroup$
KeySelect[MatchQ[_String?(StringMatchQ["Opac*"])]]@ Options[Charting`iBarLegend]
<|"OpacityFunctionTicks" -> None,
  "OpacityFunctionSize" -> Automatic, 
  "OpacityFunctionRange" -> {0, 1}, 
  "OpacityColorFunction" -> GrayLevel[0.4]|>
BarLegend[Hue, 
  LegendMarkerSize -> {30, 180}, 
  "OpacityFunctionTicks" -> All,
  "OpacityFunctionSize" -> Scaled[2], 
  "OpacityColorFunction" -> Red, 
  OpacityFunction -> 
    ((If[Inequality[9/22, LessEqual, -1. + 2.*#1, Less, 7/11], 0.01, 
        0.5, 0] & )[Rescale[#1, {0, 1}, {0.5, 1}]] & ), 
  Charting`TickSide -> Right]

enter image description here

BarLegend[{"TemperatureMap", {-1, 1}}, 
 LegendMarkerSize -> {50, 300}, 
 "OpacityFunctionTicks" -> {{0, "zero"}, {.5, "1/2"}, {1, "one"}}, 
 "OpacityFunctionSize" -> Scaled[1],
 "OpacityColorFunction" -> Black, 
 OpacityFunction -> (Rescale[Abs[#1 - 1/2], {0, 1/2}, {0, 1}] &), 
 Charting`TickSide -> Right]

enter image description here

DensityPlot3D[x y z, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
 ColorFunction -> Hue, ImageSize -> 200, 
 PlotLegends -> 
  BarLegend[Hue,
    "OpacityFunction" -> None, 
    LegendMarkerSize -> {30, 180}]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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