Minecraft_Json
Minecraft_Json

Reputation: 247

Plotly Express: Update the colorbar title

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

Upvotes: 4

Views: 3622

Answers (1)

vestland
vestland

Reputation: 61214

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()

Upvotes: 7

Related Questions