How to change the color of specific ticks in BarLegend?

You can wrap the tick labels with Style:

BarLegend[{{Red, Black, Cyan}, {0, 1}}, 
 Ticks -> {{0, Style["Hot", 13, Red]}, {1, Style["Cold", 13, Cyan]}}, 
 LegendMarkerSize -> 236]

enter image description here

Perhaps more flexibly, (whoops... this part is just a variation of the approach already posted by CA Trevillian)

cf = Blend[{Red, Black, Cyan}, #] &; 

BarLegend[{cf, {0, 1}}, 
 Ticks -> MapThread[{#, Style[#2, 13, cf@#]} &, {{0, 1}, {"Hot", "Cold"}}],
 LegendMarkerSize -> 236]

enter image description here

and

BarLegend[{cf, {0, 1}},
 Ticks -> {0, 1}, 
 "TickLabels" -> {Style["Hot", 13, cf@0], Style[ "Cold", 13,  cf@1]}, 
 LegendMarkerSize -> 236]

enter image description here

and

BarLegend[{cf, {0, 1}}, 
 "Ticks" -> {1, 0, .5}, 
 "TickLabels" -> {"Hot", "Warm", "Cold"}, 
 LabelingFunction -> (With[{col = cf[#]}, Style[#3, 13, col]] &)]

enter image description here

FWIW, using yet another undocumented option:

BarLegend[{cf, {0, 1}}, 
  "RotateLabels" -> 45 Degree, 
  "Ticks" -> MapThread[{#, Style[#2, 13, cf@#]} &, {{0, 1}, {"Hot", "Cold"}}],
 LegendMarkerSize -> 236]

enter image description here


If I understand correctly, this will produce what you want:

rbc := Blend[{Red, Black, Cyan}, #] &;

BarLegend[{rbc, {0, 1}}, 
Ticks ->
{
{#, Style["Hot", rbc[#]]}&@0,
{#, Style["Cold", rbc[#]]}&@1
}, 
LabelStyle -> {FontSize -> 13, Black}, LegendMarkerSize -> 236]

First, you recognize that BarLegend automatically creates a ColorFunction using Blend to combine the colors provided to it. Then, you can discover you may define your own! This is the rbc that I define above. Finally, with some usage of # and & to encourage anonymous function assignments, you may get the same image as @kglr, so I will not repeat that here.

I think this will provide you with the freedom to define such things as Ticks markings which change color according to the ColorFunction, but that is out of the scope of this answer.

This can be applied also to kglr's answer, asked for in the comments how to rotate labels:

BarLegend[{rbc, {0, 1}}, 
Ticks -> {{#, Rotate[Style["Hot", rbc[#]], 90 Degree]} &@
0, {#, Rotate[Style["Cold", rbc[#]], 90 Degree]} &@1}, 
LabelStyle -> {FontSize -> 13, Black}, LegendMarkerSize -> 236]

Produces:

Image of BarLegend with rotated labels by 90 degrees.