Given the heat map below from here:
flights = sns.load_dataset("flights")
flights = flights.pivot("month", "year", "passengers")
ax = sns.heatmap(flights, annot=True, fmt="d")
for text in ax.texts:
text.set_size(14)
if text.get_text() == '118':
text.set_size(18)
text.set_weight('bold')
text.set_style('italic')
How can I apply similar logic to the y-axis tick labels? For example, what if I wanted to embolden "February", make it 13 point font, and color it red?
Thanks in advance!
Almost exactly the same idea, you just need to loop over the list of yticklabels:
flights = sns.load_dataset("flights")
flights = flights.pivot("month", "year", "passengers")
ax = sns.heatmap(flights, annot=True, fmt="d")
for label in ax.get_yticklabels():
if label.get_text() == "February":
label.set_size(13)
label.set_weight("bold")
label.set_color("red")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With