Simple question with a (probably) complicated answer: How can I include the ClippingStyle colors of a ContourPlot in its BarLegend?
Take for example this plot (I know, some of the options are superfluous in this simple example, but these are essentially the options I will use later):
ContourPlot[Log[x y], {x, 0, 3}, {y, 0, 3}, PlotRange -> {0, 1}, Contours -> 9, ClippingStyle -> {Black, White}, ColorFunctionScaling -> False, ColorFunction -> ColorData["WL13DefaultDensityGradient"], PlotLegends -> BarLegend[{"WL13DefaultDensityGradient", {0, 1}}, 9] ] Evidently, Black and White are missing from the legend. How can they, and the corresponding labels 0 and 1 be included in the legend? Further requirements:
- I do not want a continuous color gradient in the bar legend
- it should work for different
PlotRanges and for different number ofContours
Is there any solution that does not involve implementing a completely new legend from scratch? I thought about redefining the ColorDataFunction, but the documentation doesn't give any insights on how to do that...
Many thanks already!


(-0.1, 0)and in white area are in range(1, 1.1)which is not true. Because of this Bob Hanlon's answer is better. $\endgroup$