This thread was very helpful for me, but I’m curious–after sorting the bars by size, how can we order the sequential colors to reflect that new sort order? Same question goes for the Legend.
For example, I want to see the sequential coloring applied evenly from left to right, but the sort order to also be largest to smallest.
tips = px.data.tips()
px.histogram(tips, x=“day”, color=“day”, height=400, width=800, color_discrete_sequence=px.colors.diverging.Spectral)
px.histogram(tips, x=“day”, color=“day”, height=400, width=800, color_discrete_sequence=px.colors.diverging.Spectral).update_xaxes(categoryorder=“total descending”)
Similarly, for something like this, how could we sort by percent non-smoker?
px.histogram(tips, x=“day”, color=“smoker”, height=400, width=800, barmode=“relative”, barnorm=‘percent’)