I have a heatmap that I created with this code:
dfreverse = df_hml.values.tolist()
dfreverse.reverse()
colorscale = [[0, '#FFFFFF'],[0.4, '#F8F8FF'], [1, '#F1C40F']]
x = [threeYr,twoYr,oneYr,Yr]
y = ['March', 'February', 'January', 'December', 'November', 'October', 'September', 'August', 'July', 'June', 'May', 'April']
z = dfreverse
z_text = np.around(z, decimals=2) # Only show rounded value (full value on hover)
fig = ff.create_annotated_heatmap(z, x=x, y=y,annotation_text=z_text, colorscale=colorscale, hoverinfo='none')
# Altering x axis
fig['layout']['xaxis']['tickfont']['family'] = 'Gill Sans MT'
fig['layout']['xaxis']['tickfont']['size'] = 12
fig['layout']['xaxis']['tickfont']['color'] = "black"
fig['layout']['xaxis']['tickangle'] = 0
# Altering x axis
fig['layout']['yaxis']['tickfont']['family'] = "Gill Sans MT"
fig['layout']['yaxis']['tickfont']['size'] = 12
fig['layout']['yaxis']['tickfont']['color'] = "black"
fig['layout']['yaxis']['tickangle'] = 25
# Altering main font
fig['layout']['font'] ["family"] = "Gill Sans MT"
fig['layout']['font']['size'] = 9
plotly.offline.iplot(fig,config={"displayModeBar": False},show_link=False,filename='pandas-heatmap')
As you can see, August to March this year doesnt have any data and thus is showing as 0. I cant remove this otherwise the heatmap doesnt work... so I was thinking I would change the font of any 0's to white to hide them. However I am not sure how to do this.
I found this code which changes the fontsize of the annotation, but not sure how to alter it to change the color if the value == 0 (as 'i' is not the value)
for i in range(len(fig.layout.annotations)):
fig.layout.annotations[i].font.size = 9

