I can't figure out how to change the title of the color-legend in plotly. (Example Image, blue circle)
If you're using px.bar
with settings that produce a colorbar, use:
fig.layout.coloraxis.colorbar.title = 'another title'
import plotly.express as px
data = px.data.gapminder()
data_canada = data[data.country == 'Canada']
fig = px.bar(data_canada, x='year', y='pop',
hover_data=['lifeExp', 'gdpPercap'], color='lifeExp',
labels={'pop':'population of Canada'}, height=400)
fig.layout.coloraxis.colorbar.title = 'another title'
fig.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.