2 added 18 characters in body

Consider a BarLegend showing a smooth gradient, like this one:

SeedRandom[36]
data = RandomReal[{-0.5, 1}, 10]

BarLegend[{"SolarColors", MinMax[data]}]


I would like to have two extra tick marks showing the actual minimal and maximal values.

MinMax[data]
(* {-0.289979, 0.789597} *)


Is there a simple way to do this using BarLegend?

I guess I could just use a DensityPlot instead. Here's an example, with the CustomTicks package. But this is a bit too complicated to write up when one is in a hurry and doesn't have personal utility functions handy. Is there an easier way?

DensityPlot[y, {x, 0, 1}, {y, Min[data], Max[data]},
PlotRangePadding -> None, ColorFunction -> "SolarColors",
AspectRatio -> 15,
ImageSize -> {Automatic, 250},
FrameTicks -> {{None,
Sort@Join[
LinTicks[Min[data], Max[data], TickDirection -> Out,
MajorTickLength -> 0.2,
MinorTickLength ->
0.1], ({#, NumberForm[#, 2], {0, 0.2}, {}} &) /@
MinMax[data]]}, {None, None}}
]


Consider a BarLegend showing a smooth gradient, like this one:

SeedRandom[36]
data = RandomReal[{-0.5, 1}, 10]

BarLegend[{"SolarColors", MinMax[data]}]


I would like to have two extra tick marks showing the actual minimal and maximal values.

MinMax[data]
(* {-0.289979, 0.789597} *)


Is there a simple way to do this?

I guess I could just use a DensityPlot instead. Here's an example, with the CustomTicks package. But this is a bit too complicated to write up when one is in a hurry and doesn't have personal utility functions handy. Is there an easier way?

DensityPlot[y, {x, 0, 1}, {y, Min[data], Max[data]},
PlotRangePadding -> None, ColorFunction -> "SolarColors",
AspectRatio -> 15,
ImageSize -> {Automatic, 250},
FrameTicks -> {{None,
Sort@Join[
LinTicks[Min[data], Max[data], TickDirection -> Out,
MajorTickLength -> 0.2,
MinorTickLength ->
0.1], ({#, NumberForm[#, 2], {0, 0.2}, {}} &) /@
MinMax[data]]}, {None, None}}
]


Consider a BarLegend showing a smooth gradient, like this one:

SeedRandom[36]
data = RandomReal[{-0.5, 1}, 10]

BarLegend[{"SolarColors", MinMax[data]}]


I would like to have two extra tick marks showing the actual minimal and maximal values.

MinMax[data]
(* {-0.289979, 0.789597} *)


Is there a simple way to do this using BarLegend?

I guess I could just use a DensityPlot instead. Here's an example, with the CustomTicks package. But this is a bit too complicated to write up when one is in a hurry and doesn't have personal utility functions handy. Is there an easier way?

DensityPlot[y, {x, 0, 1}, {y, Min[data], Max[data]},
PlotRangePadding -> None, ColorFunction -> "SolarColors",
AspectRatio -> 15,
ImageSize -> {Automatic, 250},
FrameTicks -> {{None,
Sort@Join[
LinTicks[Min[data], Max[data], TickDirection -> Out,
MajorTickLength -> 0.2,
MinorTickLength ->
0.1], ({#, NumberForm[#, 2], {0, 0.2}, {}} &) /@
MinMax[data]]}, {None, None}}
]


1

# Control the tick marks in BarLegend

Consider a BarLegend showing a smooth gradient, like this one:

SeedRandom[36]
data = RandomReal[{-0.5, 1}, 10]

BarLegend[{"SolarColors", MinMax[data]}]


I would like to have two extra tick marks showing the actual minimal and maximal values.

MinMax[data]
(* {-0.289979, 0.789597} *)


Is there a simple way to do this?

I guess I could just use a DensityPlot instead. Here's an example, with the CustomTicks package. But this is a bit too complicated to write up when one is in a hurry and doesn't have personal utility functions handy. Is there an easier way?

DensityPlot[y, {x, 0, 1}, {y, Min[data], Max[data]},
PlotRangePadding -> None, ColorFunction -> "SolarColors",
AspectRatio -> 15,
ImageSize -> {Automatic, 250},
FrameTicks -> {{None,
Sort@Join[
LinTicks[Min[data], Max[data], TickDirection -> Out,
MajorTickLength -> 0.2,
MinorTickLength ->
0.1], ({#, NumberForm[#, 2], {0, 0.2}, {}} &) /@
MinMax[data]]}, {None, None}}
]