histogram for categorical data with plotly 1

histogram for categorical data with plotly

import plotly.express as px

df = px.data.tips()
fig = px.histogram(df, x="day").update_xaxes(categoryorder='total ascending')
fig.show()

Here is what the above code is Doing:
1. We’re importing the plotly.express library as px.
2. We’re creating a dataframe called df using the tips dataset from plotly.express.
3. We’re creating a histogram called fig using the tips dataset and the day column.
4. We’re updating the x-axis to be sorted by the total number of tips per day.
5. We’re showing the histogram.

Similar Posts