Search for departure points from matplotlib: boxplot

I am drawing an abnormal distribution using boxplot, and am interested in learning about outliers using the matplotlib boxplot function.

Besides the plot, I am interested to know the meaning of the points in my code, which are shown as outliers in boxplot. Is there a way to extract these values ​​for use in my downstream code from a boxplot object?

+6
source share
1 answer

Do you mean those dots above and below the two black lines?

from pylab import * spread= rand(50) * 100 center = ones(25) * 50 flier_high = rand(10) * 100 + 100 flier_low = rand(10) * -100 data =concatenate((spread, center, flier_high, flier_low), 0) r = boxplot(data) 

enter image description here

Save the returned dict from boxplot, and you can get all the information from it, for example:

 top_points = r["fliers"][0].get_data()[1] bottom_points = r["fliers"][2].get_data()[1] plot(np.ones(len(top_points)), top_points, "+") plot(np.ones(len(bottom_points)), bottom_points, "+") 

enter image description here

+12
source

Source: https://habr.com/ru/post/913665/


All Articles