简体   繁体   中英

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

在此处输入图片说明

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

You can use:

figt.update_layout(coloraxis_colorbar_title_text = 'your title')

Plot:

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM