Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide outliers in plotly boxplot with px.box in python

I have the following boxplot in plotly for my streamlit application: `

fig = px.box(df, x=x_column, y=y_column, color=x_column)    
st.plotly_chart(fig,use_container_width=True)

I have not found a working solution to hide the outliers in my boxplot.

The boxplot:

enter image description here

The desired boxplot:

enter image description here

Anyone who knows how I can achieve this? Thank you!

like image 783
olive Avatar asked Jan 29 '26 17:01

olive


1 Answers

You can simply use points=False to remove outliers:

import plotly.express as px
df = px.data.tips()
fig = px.box(df, y="total_bill", points=False)
fig.show()

With outliers:

enter image description here

After removing outliers: enter image description here

like image 162
Phoenix Avatar answered Feb 01 '26 08:02

Phoenix