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.