You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Choosing The Algorithm For Computing Quartiles
278
+
279
+
By default, quartiles for violin plots are computed using the `linear` method (for more about linear interpolation, see #10 listed on [http://www.amstat.org/publications/jse/v14n3/langford.html](http://www.amstat.org/publications/jse/v14n3/langford.html) and [https://en.wikipedia.org/wiki/Quartile](https://en.wikipedia.org/wiki/Quartile) for more details).
280
+
281
+
However, you can also choose to use an `exclusive` or an `inclusive` algorithm to compute quartiles.
282
+
283
+
The _exclusive_ algorithm uses the median to divide the ordered dataset into two halves. If the sample is odd, it does not include the median in either half. Q1 is then the median of the lower half and Q3 is the median of the upper half.
284
+
285
+
The _inclusive_ algorithm also uses the median to divide the ordered dataset into two halves, but if the sample is odd, it includes the median in both halves. Q1 is then the median of the lower half and Q3 the median of the upper half.
286
+
287
+
```python
288
+
import plotly.express as px
289
+
290
+
df = px.data.tips()
291
+
fig = px.violin(df, y="total_bill")
292
+
fig.update_traces(quartilemethod="exclusive") # or "inclusive", or "linear" by default
293
+
294
+
fig.show()
295
+
```
296
+
277
297
#### Reference
278
298
279
299
See [function reference for `px.violin()`](https://plotly.com/python-api-reference/generated/plotly.express.violin) or https://plotly.com/python/reference/violin/ for more information and chart attribute options!
0 commit comments