3

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.

  • https://mathematica.stackexchange.com/questions/215745/force-barlegend-to-show-numbers – Rupesh Mar 07 '22 at 19:54
  • This lets me change the Ticks to specific ones, but not to make them evenly distributed even tho the values are scaled logarithmically – Marek Kuchař Mar 07 '22 at 20:26
  • I am just guessing if you want something similar to this. you can always change the legend label. It's always best to post a minimal example the problem can be recreated. https://mathematica.stackexchange.com/questions/76168/how-to-add-own-description-to-barlegend – Rupesh Mar 07 '22 at 20:45

1 Answers1

8
 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

kglr
  • 394,356
  • 18
  • 477
  • 896