Hi all,
I am trying to create faceted bar chart. Inside the faceted chart the bars are rendered in ascending or descending order.
Code
counting_edu = main_Dg.groupby([‘Education’,‘Gender’,‘Year’])[‘Numbers’].count().reset_index()
counting_edu.loc[counting_edu.Education == ‘Some college/university study without earning a bachelorâ\x80\x99s degree’,‘Education’] = ‘Without Degree’
edu = px.bar(y=counting_edu.Education,x=counting_edu.Numbers,animation_frame=counting_edu.Year)
edu.update_layout(height = 500,width = 800, title = ‘Educated Likewise’,
yaxis = {‘categoryorder’:‘total descending’})
#edu.update_yaxes(matches=None)
#edu.for_each_yaxis(lambda yaxis: yaxis.update(showticklabels=True))
edu.show()
Code End
Is there any way to achieve a sorted bars like shown below in the each facets?
Currently I have the facets like below
I have tried the following.
- working with the update_layout(xaxis ={‘categoryorder’:‘total descending’}) option.
- tried the category_order option in the px.bar() function.
Then I realized that the y-axis are common between multiple facets, so tried
3) fig.update_yaxes(matches=None)
Any ideas or thoughts would be greatly helpful.