Python >> Tutoriel Python >  >> Python Tag >> Plotly

Titre de la barre de couleurs dans Plotly Heatmap

Essayez

fig = go.Figure(
    data=go.Heatmap(z=z_values, y=[str(x) for x in params_1], x=[str(x) for x in params_2]), 
colorbar=dict(title='Title') , 
    layout=go.Layout(
        title="Analysis results",
        xaxis=dict(title='Diameter'),
        yaxis=dict(title='Max Distance')
    ),
)
fig.show()

Incluez simplement colorbar={"title": 'Your title'} en go.Heatmap() pour obtenir ceci :

Tracé :

Code :

import plotly.graph_objects as go

fig = go.Figure(data=go.Heatmap(colorbar={"title": "Your title"},
                                            z=[[1, 20, 30],
                                              [20, 1, 60],
                                              [30, 60, 1]]))
 fig.show()

Vous pouvez également le faire après en mettant à jour la mise en page :

fig.update_layout(
    coloraxis_colorbar=dict(
        title="Your Title",
    ),
)