Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide the colorbar and legend in plotly express bar graph?

I am creating a bar graph with something like this:

px.bar(df, x=x, y=y, color=c,
       title=params['title'], 
       hover_data=hover_data)

When c != None the graph produces either a legend or a colorbar. How can I remove either of them?

like image 986
Soren Avatar asked Oct 30 '19 17:10

Soren


2 Answers

This worked for me!

fig.update_traces(showscale=False)
like image 113
Kyle Pastor Avatar answered Oct 19 '22 07:10

Kyle Pastor


In v5.1.0, this works for me:

fig.update_coloraxes(showscale=False)
Before After
Bar chart with gradient color bar on right side Only bar chart
like image 31
aheze Avatar answered Oct 19 '22 06:10

aheze