Is there any way to color specific tick labels on plots?


I’m plotting some districts indicators in a heatmap and I wanted to highlight the selected districts by coloring them red in the y axis (each tick in the yaxis is a district name). I know in matplotlib you can loop through each tick, but here I’m not finding anything. Is there any way I can do this?

The relevant piece of my code is this one:

colors = ['black']*len(ranking)
idx = (ranking[ranking.district.isin(selected_districts)]).index.values
for i in idx:
    colors[i] = 'red'

As color doesn’t accept an array, my approach isn’t working. Is there any way with a lower level API to achieve this?