✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

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

Hey,

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'
fig.update_yaxes(color=colors)

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