I have the following figure:
and I would like to add the mean.
Is it possible with Plotly Express, without using Graph Objects go.Box()
?
For information, here is my code:
import plotly.express as px
fig = px.box(device_field_strength_impact_df,
y='value',
x='device_field_strength',
color='variable',
# boxmean=True,
facet_col='group',
)
fig.show()
and the pandas DataFrame:
method group patient device_field_strength variable value
expert1 experts 62 device_field_strength_1.5 F1_score 0.857
expert1 experts 66 device_field_strength_3 F1_score 0.909
... ... ... ... ... ... ...
Note: I made the same figure with Graph Objects but I don't know how to handle the legend and x labels.
As @r-beginners answered in his comment:
You can add the averages by adding
fig.update_traces(boxmean=True)
after thepx.box()
.
Indeed, the following code works perfectly:
import plotly.express as px
fig = px.box(device_field_strength_impact_df,
y='value',
x='device_field_strength',
color='variable',
facet_col='group',
)
fig.update_traces(boxmean=True)
fig.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With