plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

legend_tracegroupgap doesn't work when legend_traceorder is used

Open imirzadeh opened this issue 3 years ago • 2 comments

Note: to reproduce, see here

The problem

Baseline

long_df = px.data.medals_long()

fig = px.bar(long_df, x="nation", y="count", color="medal", title="Long-Form")
fig.update_layout(width=680, height=480,)
fig.show()

works just fine: newplot (3)

Increasing the gap works

long_df = px.data.medals_long()

fig = px.bar(long_df, x="nation", y="count", color="medal", title="Long-Form")
fig.update_layout(autosize=False, width=680, height=480, legend_tracegroupgap=50)
fig.show()

also works fine newplot (4)

Increasing the gap & reversing doesn't work

long_df = px.data.medals_long()

fig = px.bar(long_df, x="nation", y="count", color="medal", title="Long-Form Input")
fig.update_layout(width=680,height=480, legend_traceorder="reversed", legend_tracegroupgap=50)
fig.show()

gives newplot (5)

imirzadeh avatar Jul 01 '22 03:07 imirzadeh

Also legend groups don't work when using legend_traceorder='reversed': only one group header will show in the legend if the latter argument value is used, rather than showing all group headers in the legend (plotly version 5.18.0)

I'd place a note in the documentation of this argument, if this is confirmed in other versions.

matanox avatar Jun 11 '24 21:06 matanox

I can confirm that increasing the gap & reversing doesn't work on Plotly version 5.21.0 codepen.

Coding-with-Adam avatar Jun 25 '24 17:06 Coding-with-Adam