Issue
I understand that the ends of whiskers in matplotlib's box plot function extend to max value below 75% + 1.5 IQR and minimum value above 25% - 1.5 IQR. I would like to change it to represent max and minimum values of the data or the 5th and 95th quartile of the data. Is is possible to do this?
Solution
To get the whiskers to appear at the min and max of the data, set the whis
parameter to an arbitrarily large number. In other words: boxplots = ax.boxplot(myData, whis=np.inf)
.
The whis
kwarg is a scaling factor of the interquartile range. Whiskers are drawn to the outermost data points within whis * IQR
away from the quartiles.
Now that v1.4 is out:
In matplotlib v1.4, you can say: boxplots = ax.boxplot(myData, whis=[5, 95])
to set the whiskers at the 5th and 95th percentiles. Similarly, you'll be able to say boxplots = ax.boxplot(myData, whis=[0, 100])
to set the whiskers at the min and max.
Note: you could probably modify the artists contained in the boxplots
dictionary returned by the ax.boxplot
method, but that seems like a huge hassle
Answered By - Paul H
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.