Skip to content
Advertisement

Is there any way to show mean in box plot using Python?

I’m just starting using Matplotlib, and I’m trying to learn how to draw a box plot in Python using Colab.

My problem is: I’m not able to put the median on the graph. The graph just showed the quartiles, mean, and outliers. Can someone help me?

My code is the following.

JavaScript

Advertisement

Answer

I tried running your code with a sample data set where the mean and median are distinct, and like @tdy showed, as long as the parameters showmeans=True and meanline=True are being passed to the df.plot.box method, the mean and median should both show up. Is it possible that in your data set, the mean and median are close enough together that they’re hard to distinguish?

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement