Skip to main content
added 1 character in body
Source Link
Karsten7
  • 27.7k
  • 5
  • 76
  • 138

One can use a pure function to specify the ticks of a BarLegend.

f[x_, y_] := Sin[1 + x] + 2 Sin[y] + x DensityPlot[f[x, y], {x, 0, 2 π}, {y, 0, 2 π}, PlotLegends -> BarLegend[Automatic, Ticks -> (FindDivisions[{#1, #2, π}, Ceiling[(#2 - #1)/π]] &)]] 

Out

One can use a pure function to specify the ticks of a BarLegend.

f[x_, y_] = Sin[1 + x] + 2 Sin[y] + x DensityPlot[f[x, y], {x, 0, 2 π}, {y, 0, 2 π}, PlotLegends -> BarLegend[Automatic, Ticks -> (FindDivisions[{#1, #2, π}, Ceiling[(#2 - #1)/π]] &)]] 

Out

One can use a pure function to specify the ticks of a BarLegend.

f[x_, y_] := Sin[1 + x] + 2 Sin[y] + x DensityPlot[f[x, y], {x, 0, 2 π}, {y, 0, 2 π}, PlotLegends -> BarLegend[Automatic, Ticks -> (FindDivisions[{#1, #2, π}, Ceiling[(#2 - #1)/π]] &)]] 

Out

Source Link
Karsten7
  • 27.7k
  • 5
  • 76
  • 138

One can use a pure function to specify the ticks of a BarLegend.

f[x_, y_] = Sin[1 + x] + 2 Sin[y] + x DensityPlot[f[x, y], {x, 0, 2 π}, {y, 0, 2 π}, PlotLegends -> BarLegend[Automatic, Ticks -> (FindDivisions[{#1, #2, π}, Ceiling[(#2 - #1)/π]] &)]] 

Out