3
$\begingroup$

I am doing a ListContourPlot of my data, but to achieve a solid plot I needed to first take a logarithm of the "height". Now I'd like to force the ticks on my BarLegend to certain values, but I have no idea how to do that. My example

To rephrase... I have a plot (seen on the picture), but I'd like to change the labels on the BarLegend, but I need them to remain where they are. To put it simply, I need to replace each TickLabel value with its exponential.

$\endgroup$
3

1 Answer 1

8
$\begingroup$
 data = Table[3 Sin[x] Cos[y], {x, 0, 2 Pi, 0.05}, {y, 0, 2 Pi, 0.05}]; 

 ListContourPlot[data, ColorFunction -> "Rainbow", 
  Contours -> {Automatic, 30}, 
  PlotLegends -> Placed[BarLegend[Automatic, None, 
    LegendLabel -> "Spectral Density"], Below]]

enter image description here

Add the option LabelingFunction -> (Exp[HoldForm @ #3] &) to BarLegend:

ListContourPlot[data, ColorFunction -> "Rainbow", 
  Contours -> {Automatic, 30}, 
  PlotLegends -> Placed[BarLegend[Automatic, None, 
     LabelingFunction -> (Exp[HoldForm @ #3] &), 
     LegendLabel -> "Spectral Density"], Below]]

enter image description here

Note: To see the arguments of the pure function used to set LabelingFunction, inspect:

BarLegend[{"Rainbow", {-5, 5}}, None, LabelingFunction -> FOO]

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.