Reputation: 13
friends Im trying to plot my data to a boxplot.
this is my data
this is the boxplot graph
import plotly.express as px
fig = px.box(df_hb, x="QUESTION DETAIL", y="ANSWER", color="MONTH", title="Buy Price", points="outliers",
labels={"QUESTION DETAIL" : "Product", "ANSWER" : "Buy Price"})
fig.update_traces(quartilemethod="exclusive") # or "inclusive", or "linear" by default
fig.update_layout(paper_bgcolor='white',
plot_bgcolor='white',
autotypenumbers='convert types',
legend_traceorder="normal"
)
fig.show()
my problem is, i want to sort the position of bar by the month as a color. i want to move "FEBRUARY" color before "MARCH" color
Upvotes: 1
Views: 1347
Reputation: 9786
If you look at the documentation, you will see there is an attribute called category_orders
. You can add the order like that:
px.box(......,category_orders={"MONTH": ["FEBRUARY-2022", "MARCH-2022"]})
Upvotes: 1