I would like to extract the range values Mathematica is assigning colours to in a ListContourPlot
(without the range affected by clipping), in order to build custom BarLegends
with MaTeX
.
I came across this question: ShowLegend values, but since this was already more than 5 years ago, I thought somebody might have a better idea? The function provided in the answer seemingly does not work without modifying in Mathematica 11.3.
Ideas?
Edit
Sorry for not providing an example. Let's look at this plot for instance:
SeedRandom[1234]
data = Function[row,
Append[row, RandomReal[{95, 105}]]] /@ (Flatten[
Table[{i, j}, {i, 1, 3}, {j, 1, 3}], 1]);
data[[1, 3]] = 1;
ListContourPlot[data, PlotLegends -> Automatic]
Which gives
How can I now find out where Mathematica begins to assign the ColorFunction
? Clearly, the value 1 in data[[1,3]]
is clipping and therefore not part of the scale. In order to exactly rebuild such a BarLegend
, I need the maximum and minimum values for it.
Edit 2
What I finally want, is to rebuild the original legend like so
BarLegend[{ColorData["M10DefaultDensityGradient"], {86, 106}}, 9,
"Ticks" -> Range[88, 104, 2], LegendLabel -> "DIY BarLegend",
ColorFunctionScaling -> True]
without having to "guess" the range for the colours (in this case {86,106}
) but get them via code, to avoid incorrect Ticks
. Because of the clipping, these values won't just be the minimum and maximum of the data anymore, so I'm interested in where Mathematica is clipping.