Box chart: category order by median does not align with box median


I am attempting to have box chart, with categories ordered by median. My expectation is that the median line drawn inside the boxes should appear in the sorted manner, but this does not happen:

df_apps_ok_paid = df_apps_ok[df_apps_ok.Type=='Paid'], y='Rev_Estimate', x='Category', title="How much can paid apps earn?")
fig.update_yaxes(type='log', title="Paid app ballpark value")
fig.update_xaxes(categoryorder='median descending')

As you can see the median whiskers are all over the place, up and down, while I expected them to be in order top-left to bottom-right.

I guess it is because Box chart excludes the outliers and the code behind the categoryorder property does not? Is this by design and will remain this way or are there workarounds? Can’t seem to find anything in the dox on this: Layout.xaxis in Python .


Here is an example of ordering the box chart based on the medians with a default plotly dataset:

df =['sex', 'smoker', 'day', 'time']) #Drop non-numerical columns
df = (df-df.mean())/(df.std()) #Scale them all to make them comparable
df = df.reindex(df.median().sort_values().index, axis=1) #Reorder the columns based ob their median
fig =

By reordering the dataset based on medians, we have it displayed based on the same order.
Hope that helps!