Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotly Express: Update the colorbar title

Tags:

python

plotly

I'm using plotly Express density_heatmap and i'm trying to update manually the name of the legend (here the color continuous scale). I tried with labels, update_layout but it looks like i can't remove the 'sum of' or 'count' etc from the legend. Here i modified example from plotly:

import plotly.express as px
dft = px.data.iris()
figt = px.density_heatmap(dft, x="sepal_width", y="sepal_length", z='sepal_length',
                         labels=dict(z='sepal_length'))
figt.show()

enter image description here

Is there a way to remove this sum of? Thanks in andvance

like image 752
Minecraft_Json Avatar asked Oct 24 '25 04:10

Minecraft_Json


1 Answers

You can use:

figt.update_layout(coloraxis_colorbar_title_text = 'your title')

Plot:

enter image description here

Complete code:

import plotly.express as px
dft = px.data.iris()
figt = px.density_heatmap(dft, x="sepal_width", y="sepal_length", z='sepal_length',
                         labels=dict(z='sepal_length'))

figt.update_layout(coloraxis_colorbar_title_text = 'your title')
figt.show()
like image 143
vestland Avatar answered Oct 26 '25 17:10

vestland