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?
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?
For the legend, you can use either fig.update_traces(showlegend=False)
or fig.update(layout_showlegend=False)
.
For the colorbar, you can only use fig.update(layout_coloraxis_showscale=False)
. On normal plotly figures, you could also do fig.update_traces(marker_showscale=False)
, but it does not work for plotly express because of how facetted traces need to share the same colorscale .
go.Heatmap
, (i.e. using graph_objects, not plotly express). You must first specify a coloraxis when making the Heatmap trace e.g. go.Heatmap(..., coloraxis='coloraxis')
. Alternatively, fig.update_traces(showscale=False)
will do the trick. –
Request This worked for me!
fig.update_traces(showscale=False)
fig.update_layout(coloraxis_showscale=False)
worked for me in plotly 5.6.0
To hide the colorbar with plotly express using Plotly V4:
fig.update_traces(
marker_coloraxis=None
)
In addition to the options already presented, fig.update_layout(coloraxis_showscale=False)
works, too.
I find I often use fit.update_layout()
already, so it's nice to be able to get rid of the colorbar in the same method call.
Adding
fig.update_layout(showlegend=False)
worked for me in plotly version 5.15
© 2022 - 2024 — McMap. All rights reserved.
fig.update_traces(marker_showscale=False)
does work for me in Plotly express (I'm on using Plotly version 3.10.0) – Stuart